How to Calculate Rolling 12-Month Counts Using Power Pivot and DAX
Question details
The user needs to dynamically calculate a rolling 12-month count of specific events (such as client contacts) while preventing double-counting if the event occurred within the previous 12 months, using DAX to avoid slow worksheet formulas.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Structuring data in Power Query and writing DAX measures in the Excel Data Model to track unique occurrences over rolling periods.
- Observed behavior
- Standard worksheet formulas checking for 12-month duplicates are causing performance issues and making the workbook slow. A transition to Data Model measures is required.
Ensure your data model includes a dedicated, continuous Calendar (Date) table that is officially marked as a Date Table, and verify that your main fact table contains unique identifiers for clients.
Normalize Data and Use DAX Measures for Rolling Counts
Optimize performance by structuring data correctly in Power Query and utilizing DAX time intelligence to evaluate rolling 12-month periods.
DAX measures evaluate context dynamically, making them much faster than traditional worksheet formulas for complex conditional counting.
To achieve accurate rolling periods, your data must be structured logically with one row per event, rather than having dates spread across multiple columns.
If your months are stored in separate columns, open the Power Query Editor, select the month columns, right-click, and choose 'Unpivot Columns' to create a flat, normalized list of dates.
Load the normalized data into the Data Model. Open Power Pivot, navigate to Diagram View, and create a relationship between your event dates and a dedicated Calendar table.
Write a measure using DAX functions like CALCULATE and DATESINPERIOD to define the trailing 12-month window based on the current context date.
Use the FILTER and COUNTROWS functions within your measure to check if a qualifying contact exists for the specific Client ID in the prior 12 months. Configure the measure to return 0 if true (already counted) or 1 if false.

Track First Contact Occurrences per Month
If a strict rolling 12-month check is too complex, approximate unique engagements by isolating only the first contact date per client per month.
Experience Fast and Reliable Data Analysis with WPS Office
While advanced DAX and Power Pivot data models are specific to Microsoft Excel, WPS Office provides a lightweight, highly compatible alternative for standard data analysis, pivot tables, and complex array formulas without the heavy resource usage. Enjoy seamless file compatibility and a familiar interface at no cost.

Frequently Asked Questions
Why is my Excel workbook slow when calculating rolling 12 months?
Standard worksheet formulas recalculate constantly and consume significant memory when applied across thousands of rows. Moving this logic to Power Query and DAX measures in the Data Model handles complex logic much faster.
Do I need to unpivot my data for a rolling 12-month DAX measure?
Yes, if your months are currently stored as separate columns. DAX time intelligence functions require a normalized structure where dates are listed in a single column alongside their corresponding values.
Can I use calculated columns instead of measures for rolling counts?
While possible, it is not recommended. Calculated columns compute row-by-row during data load, which increases file size. Measures compute on demand based on your PivotTable filters, making them more efficient for dynamic rolling logic.
What is a Date Table and why do I need it in Power Pivot?
A Date Table (or Calendar Table) is a continuous list of dates covering your entire data range. It allows DAX functions to accurately filter and calculate over time periods, such as a rolling 12-month window, even if your actual data is missing certain dates.




