Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I have a sales data and I want to calculate average sales of last 3 months before the current month. For example, if the current month is may of 2023, then the measure should calculate the average of april, march, and february. Although I have already had a measure which works well till now, because the year changed now the measure does not calculate the average of last 3 months. I mean, if the current month is january of 2024, then the measure does not calculate the average of december, november, october. The dax formula is the following:
Solved! Go to Solution.
HI @Anonymous,
You can try to use the following measure formula if it suitable for your scenario:
formula =
VAR currDate =
MAX ( 'calendar'[Date] )
RETURN
AVERAGEX (
SUMMARIZE (
FILTER (
ADDCOLUMNS (
ALLSELECTED ( 'Fact' ),
"Year", YEAR ( 'Fact'[Date] ),
"Month", MONTH ( 'Fact'[Date] )
),
[Date]
>= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 3, DAY ( currDate ) )
&& [Date] < currDate
),
[Year],
[Month],
"Total", [sum_sales]
),
[Total]
)
Regards,
Xiaoxin Sheng
HI @Anonymous,
You can try to use the following measure formula if it suitable for your scenario:
formula =
VAR currDate =
MAX ( 'calendar'[Date] )
RETURN
AVERAGEX (
SUMMARIZE (
FILTER (
ADDCOLUMNS (
ALLSELECTED ( 'Fact' ),
"Year", YEAR ( 'Fact'[Date] ),
"Month", MONTH ( 'Fact'[Date] )
),
[Date]
>= DATE ( YEAR ( currDate ), MONTH ( currDate ) - 3, DAY ( currDate ) )
&& [Date] < currDate
),
[Year],
[Month],
"Total", [sum_sales]
),
[Total]
)
Regards,
Xiaoxin Sheng
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 46 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |