Create a 12-Month Moving Average of a DAX Measure in Power BI
Question details
Calculate a rolling 12-month average of a distinct transaction measure in Power BI.

- Product
- Microsoft Power BI
- Device & OS
- not provided
- Scenario
- A report needs to show the average monthly distinct transaction count over a rolling 12-month period.
- Observed behavior
- The desired chart displays a moving average calculated from monthly distinct transaction counts using a dedicated date table.
Confirm that your transaction table has a transaction ID and a date column, and identify the measure you want to average. Use date-only values for the relationship and ensure your date table covers the reporting period.
Use a date table and DAX to average monthly transaction counts
Use DATESINPERIOD to define the rolling window and AVERAGEX to average the distinct transaction measure by month.
The example averages monthly distinct counts, not the distinct count across the entire 12-month window. Replace the example table and column names with those in your model.
In Power BI Desktop, select Modeling > New table and enter a calendar covering your reporting period, for example: Date = CALENDAR(DATE(2023, 1, 1), DATE(2026, 12, 31)). Adjust the dates to suit your data.
Select the Date table, choose New column, and enter: MonthStart = DATE(YEAR('Date'[Date]), MONTH('Date'[Date]), 1). This gives each month a sortable date value.
Select the Date table and use Table tools > Mark as date table, choosing Date[Date]. In Model view, create an active one-to-many relationship from Date[Date] to Transactions[TransactionDate].
Select Modeling > New measure and enter: Distinct Transactions = DISTINCTCOUNT(Transactions[TransactionID]). If you already have a suitable measure, use its name in the next step instead.
Select Modeling > New measure and enter: 12-Month Average = CALCULATE(AVERAGEX(VALUES('Date'[MonthStart]), CALCULATE([Distinct Transactions])), DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -12, MONTH)).
Add a line chart in Report view. Place Date[MonthStart] on the X-axis and [12-Month Average] on the Y-axis. Use the month column itself rather than its automatic date hierarchy.

Explore transaction data in WPS Spreadsheets
WPS Office is a free, lightweight Office alternative with a familiar interface for working with exported transaction data. It supports common Microsoft Excel formats, making it easy to move spreadsheets between applications. It does not edit or calculate Power BI DAX measures.

Frequently Asked Questions
Why should I use a separate date table?
A continuous date table provides consistent date filtering for DATESINPERIOD. In Power BI Desktop, mark it through Table tools > Mark as date table and relate its date column to the transaction date.
Is this the same as a distinct count over 12 months?
No. The measure calculates a distinct count for each month and then averages those monthly counts. A single transaction ID appearing in multiple months can contribute to more than one monthly count.
Why does the first chart point use fewer than 12 months?
The available date table or transaction history may not cover the full preceding period. Check the Date table range and the earliest transaction date before interpreting early values.
How do I include months with no transactions as zero?
Replace [Distinct Transactions] inside the AVERAGEX calculation with COALESCE([Distinct Transactions], 0). This makes blank monthly results contribute zero to the average.
Which date field should I put on the chart axis?
Use Date[MonthStart] from the related date table on the X-axis. It distinguishes months across years and provides a chronological monthly axis.




