24. Power Pivot and the Data Model
24.8 A Simple Time-Intelligence Measure
1. Agree which dates you are comparing
It is the middle of November and your internship supervisor asks whether sales have grown. You have a spreadsheet with the November orders received so far. If you divide that partial November value by sales for all of October, the answer can sound like demand fell. If you compare the same first fifteen days in each month, you might describe growth. Both fractions can be correct, and each answers its own calendar question. A report should tell the reader which days contributed.
This lesson uses the fictional FreshGo and MarketRush orders from the start of the chapter. The approved October file contributes six orders and ₹1,005. November contributes six orders and ₹1,310. The workbook has a separate Calendar table with each date in 2026. We will create expressions that move or extend the date selection before asking the model to sum sales. That is the reason for the term time intelligence. We are making date comparisons reusable across the same Data Model.
Write a precise request before creating the calculation
- Sales this month. Sum the accepted order amounts in the current Calendar month selection. An October row shows October. A November row shows November.
- Sales in the comparable period before it. For the full November row, evaluate October sales. If a learner chooses November 1 to 15, decide whether to shift those days one month back or deliberately use the entire preceding month.
- Change in money and change as a percent. Subtract prior comparable sales to get a rupee difference. Divide that difference by prior comparable sales to express it relative to the starting level.
- Sales accumulated in the calendar year. Sum the accepted facts from January 1 through the date reached in that report cell, retaining other qualifying filters such as City. Show the source coverage limitation next to the accumulated figure.
Run the lesson on fictional data in a practice copy. A real business may use a financial year ending on a different day or trading weeks aligned to weekdays. Month-to-date across two calendar months also need not have the same number of working days. Those are business choices you can document. This exercise uses calendar months and a calendar year so you can trace the dates by hand before choosing a more advanced definition.
The calculation follows the report’s dates. Save the chosen current window, prior comparison window and source coverage together with the result. You will be able to reproduce why the same sales model returns several legitimate percentages.
2. Prepare the date list and its relationship
Build time intelligence on one date row for each day
Use the Calendar table from lesson 24.5. For the 2026 fixture, it has 365 unique dates from January 1 through December 31. The entire year is useful even though the orders cover just two of its months. October 1 is a valid calendar day without an order in the sample. The end of November is also a valid calendar day even though the last sample order occurred on November 27. The Calendar supplies the date selection; the fact table supplies the matching sales data.
Verify that Calendar[Date] has the proper date type, all dates and no duplicates or blank dates. Relate it to Orders[Date] on the many side and mark Calendar as the date table with its Date column using the supported Windows desktop Power Pivot authoring controls. If incoming Orders values have times but the calendar dates represent midnight, keep the original timestamp and create a suitable day field for the relationship. Derive the business day using the agreed calendar and time zone before you discard time information. The practice data already uses day-level dates.
- Confirm the date relationship in the model. In a temporary PivotTable from the Data Model, put the Calendar year and month in Rows or use the year-aware month label built earlier. Add Total Sales from the model as the value.
- Find October 2026 and November 2026 in chronological order. Verify ₹1,005 and ₹1,310 before adding any comparison measure. Check the source register and clear other filters while you establish these controls.
- Use a three-cell check at the date level. November 2 has ₹270, November 6 has ₹220, and November 1 has no contributing transaction. A December date likewise has no matching records in the practice source.
- Put City from Stores into the same test as a slicer or filter and choose Pune. October and November should now show ₹540 and ₹400. If every month still reports the same value, inspect the date relationship or field source. If City has no effect, verify the StoreID relationship separately.
Keep a source coverage record at the correct level
A complete date spine lets a calculation name every day of the year. The approved folder or receipt register tells a different story about which sales periods the producer supplied. You cannot diagnose missing files from dates alone. A store can open only on selected days. A correct month can legitimately have no orders on several days. A single recorded order on November 29 also does not certify that all earlier November orders arrived. Distinguish the expected source coverage, the actual files received and the dates found in rows.
Someone reading “2026 YTD ₹2,315” might infer that the file certifies January through November for a real business. In this workbook, tell the reader the sample contains two approved months and no earlier sales facts. In a live reporting environment, decide whether prior months were out of scope, explicitly confirmed with zero activity or still awaiting files. A label such as “2026 YTD from approved receipts, October–November exercise” helps keep the claim within its evidence.
3. Make the model evaluate the intended days
Build the base amount and prior-window result
Check that the Total Sales measure defined in 24.7 already exists in the model. Its definition sums the recorded order amounts. In the Excel Power Pivot New Measure dialog, give each new measure a name, then enter the expression beginning with the existing equals sign. The documented one-line definitions below show the name with the expression after it. Use the supported separator for your Excel client if it differs from the commas shown here.
Total Sales := SUM(Orders[Amount])
Sales LM := CALCULATE([Total Sales], DATEADD(Calendar[Date], -1, MONTH))
Prior Full Month Sales :=
CALCULATE([Total Sales], PREVIOUSMONTH(Calendar[Date]))
Sales Change := [Total Sales] - [Sales LM]
MoM % := DIVIDE([Total Sales] - [Sales LM], [Sales LM])
Sales YTD := TOTALYTD([Total Sales], Calendar[Date])
DATEADD(Calendar[Date], -1, MONTH) takes the current selection on the date column and supplies a shifted date set. The -1 asks for one interval backward. MONTH names the interval without quotes. CALCULATE then evaluates the base sales measure for the shifted dates. It can still honor an independent City filter. The date table’s continuous range lets the function find dates on which there happen to be no orders.
PREVIOUSMONTH(Calendar[Date]) uses the first date in scope to identify the preceding calendar month and supplies that month’s dates. For a November row containing all of November, both prior-month expressions give the approved October sales. When the month is only partly selected, their different inputs lead to different answers. Keep the name of each measure aligned with the report question. In the full-month exercise Sales LM means a one-month shift. In the partial-month experiment we label it Sales in shifted window in the evidence.
The current-minus-prior formula calculates a rupee change. The percent change divides by the prior amount, using its magnitude as the comparison base in this positive-amount exercise. Label the absolute change as rupees and apply percentage display to the ratio. Using the current amount as the denominator answers a different question. In November ₹305 divides by ₹1,005 to give about 30.3%, while ₹305 divided by ₹1,310 is about 23.3% of current sales. Formats can display both attractively; the denominator determines the meaning.
Use a complete date selection for classic DATEADD
The classic date-column form expects a contiguous set of dates in the current date context. Selecting October and December together while omitting November yields a gap. Running the expression in a cell whose own date context contains that disjoint selection can raise an error. Individual month cells may still be contiguous, even when the total cell is not. If your purpose is a comparison for each month, use one month per row and test each row before deciding whether to display a grand-total comparison. For a November 1–15 snapshot you can select a continuous range without gaps.
Calendar months have different numbers of days. The documented date-column function can extend the shifted range to the end of the target month when your selection includes the last two days of the original month. A month-end shift test therefore deserves its own expected dates. The early-month lab below stays well clear of that behavior. In a workbook that must match an organization’s selling days exactly, design and verify the appropriate period mapping instead of relying on a verbal promise such as “every date aligns exactly.”
4. Read the finished report and check the denominator
Walk from one November row to its October evidence
| Calendar month | Sales ₹ | Sales LM ₹ | MoM change | Sales YTD ₹ |
|---|---|---|---|---|
| October 2026 | 1005 | Blank | Blank | 1005 |
| November 2026 | 1310 | 1005 | 30.3% | 2315 |
- Choose the November month row. For Total Sales, admit the approved November records. Their amounts total ₹1,310.
- For Sales LM, move the Calendar selection to the prior comparable month. The approved six October records total ₹1,005. City or product filter changes can narrow those October records further.
- Subtract 1,005 from 1,310. The positive result is ₹305. Divide 305 by 1,005 and format the result as a percentage with one decimal place to obtain 30.3%.
- For Sales YTD, the expression reaches from the first day of the year to the last date in the November context. Both sample months contribute, giving ₹2,315. The calendar itself supplies no extra sales amounts.
- Repeat in October. September dates exist in Calendar. The fixture has no matching September order records, so the previous total and ratio are blank. October’s own sales and YTD value remain ₹1,005.
Test a city that moved against the overall direction
| City | October ₹ | November ₹ | Change ₹ | Change % |
|---|---|---|---|---|
| Pune | 540 | 400 | −140 | −25.9% |
| Nashik | 180 | 490 | 310 | 172.2% |
| Nagpur | 195 | 160 | −35 | −17.9% |
| Solapur | 90 | 260 | 170 | 188.9% |
Pune fell by ₹140 even as the full set grew by ₹305. Nashik grew by ₹310 and Solapur grew by ₹170. Nagpur fell by ₹35. These four money changes add to the overall money change. Each city’s percentage uses its own October denominator. To report the overall percentage, first combine the money figures and then calculate the ratio at the overall comparison scope. A simple mean of the city percentages would give each city equal weight. The rupee-weighted comparison follows the approved starting amounts.
Headline percentages can exaggerate a small starting base. Solapur grew about 188.9% from ₹90, while Nashik’s lower percentage of 172.2% represented a larger money change of ₹310. For a staffing or inventory decision, display the current amount, prior amount, change in money and percent change in the same view. Use a distinct note for partial windows. A team should be able to see both scale and trend direction before assigning resources.
5. Read an accumulated result as of one date
YTD overlaps earlier rows by design
TOTALYTD evaluates a measure for the dates through the current year-to-date boundary. The default calendar year ends December 31. In October, ₹1,005 represents approved sales since the beginning of 2026 through the October cell’s endpoint. In November, ₹2,315 already includes that October contribution. If you add the two YTD cells, you get ₹3,320, which counts October twice. A period sales measure makes the monthly amounts explicit. A YTD column shows how much has accumulated at successive checkpoints.
Choosing a city changes the qualifying facts even when the date coverage is the same. Pune’s YTD reaches ₹540 at October and ₹940 at November. Consider November 1 to 15 as the date context instead. With all cities eligible, the current sample contributes ₹910 during those days; YTD to that cutoff includes ₹1,005 in October plus ₹910 in November, so it reaches ₹1,915. Through November 15 for Pune alone, the YTD value reaches ₹810 because October Pune ₹540 and the November 2 Pune order ₹270 are eligible. The current date boundary changes what the measure accumulates.
A wide PivotTable can have a month row for December even when there are no December fact rows in the practice source. A YTD value can still show ₹2,315 in that date context because the earlier months qualify. That does not attribute ₹2,315 to December. Compare the YTD figure with the month’s own sales and receipt status before presenting it as a current trend. If you hide future or unapproved periods, be explicit about the allowed report cutoff. A monthly PivotTable row naturally ends at the month boundary, while your operating data may only have been checked through a particular earlier day.
Plan a new fiscal definition with business signoff
An employer might close its reporting year on March 31, so April begins a new year-to-date period. The classic DAX function allows a fiscal year-end argument in its documented syntax. That date literal is interpreted according to the client locale. Fiscal labels and quarter sorting also need to follow that convention. Before changing the exercise’s calendar-year measure, build an approved fiscal calendar for all relevant dates and test just before and just after a year boundary. Carry the chosen period in the report metadata. A rolling twelve-month figure answers a different question because its start date moves as the cutoff advances.
6. Change the comparison period without changing the facts
November 1–15 gives two defensible October references
In the first half of November, the recorded orders are O-107 for ₹270, O-108 for ₹220, O-109 for ₹160 and O-110 for ₹260. Their total is ₹910. The shifted window October 1–15 has O-101, O-102 and O-103 for ₹128, ₹180 and ₹195, yielding ₹503. The preceding full calendar month, October 1–31, also includes O-104, O-105 and O-106 and yields ₹1,005. Both references come from the same approved workbook. The different day boundaries account for the different amounts.
| Comparison rule | November ₹ | Prior ₹ | Change ₹ | Change % |
|---|---|---|---|---|
| Shift November 1–15 to October 1–15 | 910 | 503 | 407 | 80.9% |
| Use October 1–31 as the prior period | 910 | 1005 | −95 | −9.5% |
If the team’s question is “How far have we progressed relative to the previous full month?” the second reference is sensible. A suitable label is “November 1–15 compared with October full month.” If the team asks “How does the first half compare with the first half?” use the first policy and a label such as “Nov 1–15 vs Oct 1–15.” Confusing one reference with the other can reverse the message. Include the actual date boundaries and keep the figures tied to the approved files.
Handle unknown, no activity and a recorded zero separately
With no September transactions in the input, the October prior measure returns blank. That result has a narrow meaning: the current scope and data produce no prior amount. It does not reveal whether the September file was received or whether the business was operating. The source register provides that status. Your dashboard can leave the percentage blank and label its comparison “prior sales unavailable.” Do not manufacture a denominator from the first visible row.
With a confirmed zero prior amount and a positive current amount, the difference in rupees is useful, and the percentage is undefined because the denominator is zero. DIVIDE returns blank by default. With a genuinely recorded zero current amount and a positive prior amount, a minus one hundred percent change is meaningful under the policy. If current is blank and prior exists, directly subtracting prior from blank can compute a misleading negative change. Test for blank separately so your report can distinguish missing evidence from a real zero.
MoM % When Both Periods Have Values :=
IF(
OR(ISBLANK([Total Sales]), ISBLANK([Sales LM])),
BLANK(),
DIVIDE([Total Sales] - [Sales LM], [Sales LM])
)
Sales Change When Both Periods Have Values :=
IF(
OR(ISBLANK([Total Sales]), ISBLANK([Sales LM])),
BLANK(),
[Total Sales] - [Sales LM]
)
The guard confirms both measures have values, and the division still guards a zero prior denominator. Keep the source coverage audit alongside this formula. A partially received month can already contain some positive sales and pass the blank test. Report approval depends on the agreed intake status or an explicit as-of label and like-for-like comparison. A data owner can declare a confirmed no-activity month and authorize an explicit zero presentation under a defined policy. Avoid applying that policy to a period whose sources remain unconfirmed.
7. Track the date window in a November cell
Map each step from the selection to the figure
Start with the full November month
The Calendar provides every day in November. Six approved Orders rows match that selection and add up to ₹1,310. Save both the date boundary and the source row count.
Shift one month backward
The classic full-month shift selects the October dates for this comparison. The measure sums six October records and gives ₹1,005. A retained city filter can narrow both amounts.
Limit November to the first fifteen days
The current selection now admits four order records and ₹910. A comparable shifted window selects October 1–15, for three records and ₹503. Compare those two amounts using the prior denominator.
Ask for the whole preceding month
PREVIOUSMONTH uses the earliest November date in scope to determine October. The prior reference returns ₹1,005 for the entire calendar month. Give this alternative its own scope label.
8. Verify full-month, partial-month and missing-period cases
Lab A — Rebuild the month and city controls
- Copy the approved small workbook before making changes. Use the exact sample inputs and the full 2026 Calendar from lesson 24.5. Compare set membership and dates on paper if your installed client lacks the authoring controls.
- Create a model PivotTable using a calendar year and month label for Rows and the four measures Total Sales, Sales LM, MoM % and Sales YTD for Values. Show October and November. Confirm the original ₹1,005 and ₹1,310 values before analyzing comparisons.
- Sort periods chronologically. Save the November absolute change of ₹305 and percent change of 30.3%. Confirm the October prior and percent are blank while YTD returns ₹1,005. Check the October receipt as independent evidence.
- Add City from Stores to the report and test Pune, Nashik, Nagpur and Solapur separately. Use the indicated monthly base amounts and verify the signs. Watch how a Pune November decrease can coexist with overall November growth.
- Clear the filter and compare YTD at each month boundary. Write “YTD through November 30 from the accepted sample” for ₹2,315. Clear the display of any unsupported comparison subtotal if a total row’s date scope no longer matches the intended monthly question.
Expected state. November Sales LM returns ₹1,005, November Sales YTD ₹2,315 and Pune November change −25.9%. If month sales agree but prior sales do not, confirm the Calendar date field and the filter context on that cell before changing the formula. If the month results do not agree, inspect fact dates and the base measure first.
Lab B — Prove the meaning of a partial selection and blanks
- Make a separate comparison PivotTable from the same model. Use a date-level report selection on
Calendar[Date]that covers November 1–15 inclusively. Use a Calendar date timeline or an equivalent true date range supported by your Excel version. Clear any earlier city, month and date selections that would interfere. - Compare the two prior measures with Total Sales. Trace qualifying order IDs from the source. Expect current ₹910, shifted prior ₹503 and prior whole month ₹1,005. Record changes of ₹407 and −₹95 and label them with their exact windows.
- Set the date filter to December 2026 in the same practice file. Confirm that this file has no December facts. The full December date context can still see November ₹1,310 as its prior sales. The guarded percent remains blank because current Total Sales has no matching fact values. Check how your PivotTable displays empty cells.
- In a separate scratch test with manually supplied values, try current zero with prior ₹1,310 and then current ₹1,310 with prior zero. Expect −100% in the first test and undefined in the second. If you model a confirmed no-activity policy, record how a genuine zero is represented.
- Optionally copy the workbook again and insert a clearly fictional accepted September 20 order for ₹200 under a new ID and valid lookup keys. In the experimental copy, refresh the model and display only October and November. October remains the first visible row and now has a valid ₹200 prior amount. Restore the original copy after verifying the case.
Expected state. In the extra September example, October growth relative to ₹200 is 402.5%, and the YTD through November rises to ₹2,515. The calendar already included September 20. Adding its hypothetical fact altered the result without changing the visibility of the month rows. Use the thought experiment if native tools are unavailable.
9. Review the period report before release
Diagnose results by testing the layers in order
- All month values look identical. Build a temporary Calendar by Total Sales table and click one actual event date. If it still returns the overall sales amount, confirm the report’s model source and active date relationship before reading the comparison measure.
- One month is unexpectedly low. Confirm the accompanying file, cutoffs and approved row count. A date label appearing in the Calendar can coexist with a missing or partial file. Verify date parsing and eliminate duplicates or rejected batch scope changes using the intake controls.
- Only prior sales look unexpected. Compare the first and last date of the current scope with your intended prior calendar window. Verify whether the expression shifts the current dates or selects an entire previous month. Check any date slicer or timeline connected to the report.
- A summary shows an error but monthly rows work. Inspect the date dateset of that summary. A missing month between selected ranges can make the classic DATEADD requirement fail for the total even though each individual month works. Choose an appropriate exact comparison window or omit the unsupported summary.
- An initial month has a positive prior measure. See whether an older month is present and approved in the sources. A relative calculation can reach prior dates outside the current display. The first row that happens to be visible has no special mathematical meaning.
- The summary overstates current demand. Check whether you read an accumulating YTD or a monthly period value. At the end of a confirmed December without transactions, a year-to-date figure can carry earlier sales forward.
Explain the period in a short release note
For a full-month report, use phrasing such as “Approved November 2026 sales are ₹1,310 versus ₹1,005 in October. The increase is ₹305, or 30.3% of October sales. This sample has no prior approved months beyond the two received files.” If there is a partial period, give an exact as-of date and matching comparison policy. The source receipt’s approval date, cutoff and version should be part of the evidence even if your final caption stays short.
Test at least one change in year, one leap-day boundary when those years are present, a normal month, and a scope with no sales before reusing the formula in a different workbook. Check that the model Calendar includes the whole years required by the report. If the prior comparison should intentionally span December to January, the earlier December dates and their accepted facts must be available. If a training workbook holds a single year plus no prior-year information, explain that limitation in the report design.
For a store-level decision, ask one additional question about the proposed action. A difference based on business closures, a sale event or a late file may demand a different response than underlying demand growth. The measure performs the approved arithmetic for its scope. Use the source logs and a short annotation to explain what evidence accompanies that observed change.
Choose what counts as a comparable business day
Imagine the same fictional store opened on only the first two weekends in October but opened every day during the first half of November. The October 1–15 and November 1–15 selections still use identical day numbers. They answer a question about sales within matching calendar ranges. To investigate whether an average open day became busier, ask the operations team for the business calendar. It needs the planned or actual open days for that store, and it may vary by location. Count the approved open days separately for each comparison window, then compare sales per open day. Counting days with transactions can exaggerate this average, since an open day with no purchases would be omitted.
For example, suppose an approved schedule says there were four open days in one period with ₹800 of sales and eight open days in another with ₹1,200. Sales rise by ₹400, or 50%. Average sales per open day move from ₹200 to ₹150, falling 25%. Those are separate indicators. Present the calendar scope and the operational denominator beside each number. If stores open under different schedules, compare at store and date grain before building a chain-wide figure. The current exercise uses a shared date lookup and has no opening schedule data, so its claims stay with approved amounts.
Save at least one receipt test around a boundary
A sales import at midnight may belong to the preceding store trading day under the agreed local rules. A file name such as November also describes producer packaging and can include a correction to late October. If a producer sends an October adjustment in the November receipt, keep the receipt identity and approved event date in separate fields. Sum it in the approved October event period while accounting for its arrival through the November source audit. For a previously released report, record how the month totals changed and whether the revised publication replaces the earlier comparison.
Use a simple check before delivery. Select the last eligible day just before this boundary and the first day just after it. Write the expected IDs below each date as in the partial-window lab. Preserve the original date text or timestamp as source evidence when your query derives a model date. A handful of explicit, accepted boundary records is often more useful for finding a timezone or locale issue than an all-year PivotTable which happens to show the same grand total. Date misclassification can move money between months while leaving its annual sum intact.
10. Check your reasoning
Quick checks
1. What is November’s percentage change across both approved months?
November is ₹1,310 and the comparable October full month is ₹1,005. The change is ₹305. Divide by the October baseline to get about 30.3%.
2. Why does October’s prior measure return blank in the original model?
September dates are in the Calendar, and the accepted Orders sample contains no September rows. The prior measure has no eligible sales amount. In the alternative source with a September ₹200 order, it returns ₹200 for the first displayed row.
3. Why can November 1–15 yield ₹503 and ₹1,005 as prior amounts?
A one-month shift on this early-month date set returns October 1–15 and its ₹503. PREVIOUSMONTH finds the entire calendar month before the first selected November date and returns October’s ₹1,005.
4. How much has Pune accumulated by the end of November?
₹940 in these two accepted months. Pune shows ₹540 in October and ₹400 in November. Add the underlying period amounts. The November YTD result already includes October.
5. Does a complete 2026 Calendar prove the year-to-date sales source is complete?
No. It provides day coverage for the calculation. The producer’s manifest, cutoff and row-count reconciliation provide evidence of whether the expected orders are available.
Interview practice
1. How do you explain DATEADD inside CALCULATE to a team member?
Start with the dates selected by the cell. Shift that date set by the specified interval, then evaluate the saved sales definition for the resulting dates. Keep independent filters such as City. Demonstrate January or the original November/October case using dates from a complete Calendar.
2. How do you guard the percentage from a missing current period?
Check both sales values for blank, then use DIVIDE with the prior denominator. Record intake status separately so a partial file containing some positive amounts still needs approval. A recorded zero current amount remains a different valid input when the prior amount is positive.
3. What would you do when October and December are selected with November excluded?
Test the actual date context of each DAX cell. Individual month selections can still contain contiguous dates, while a combined context can fail the classical date-column DATEADD requirement. Use a valid contiguous scope for the intended comparison or avoid displaying the combined calculation.
4. When is November YTD larger than November sales?
When prior dates in the calendar year contribute positive accepted values after retaining the non-date filters. In the full sample November adds ₹1,310, and YTD also includes ₹1,005 from October. A date context inside November can set an earlier endpoint.
5. How could Solapur have higher percent growth than Nashik while contributing less extra money?
Solapur increases ₹170 relative to a ₹90 October base. Nashik adds ₹310 relative to a ₹180 October base. The larger relative growth and the larger money increase occur in different cities because the denominators differ. Show both for a resource decision.
Six revision cards
- Calendar and coverage. Complete date rows provide date selections. Confirm file coverage and money separately.
- Previous period. Shift the current date window with DATEADD or use the entire prior month with PREVIOUSMONTH. Decide the question first.
- Measure context. Date ranges can change while city and product filters still constrain eligible orders.
- Growth denominator. Use the prior comparable amount. Show blank for a zero denominator and keep absent values distinct.
- YTD. Read the accumulated value at one endpoint. Adding successive YTD cells counts some dates twice.
- Evidence before release. Save a known month, a city result, a partial period and a missing-period case with scope and values.
Compare the original before and after month report with your worksheet. More exercises are available in the Excel Practice Task Hub. Continue with model PivotTables and CUBE functions, or see the separate Power BI course.