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!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi everyone.
I have encounter an issue on my report and need your help.
I need a calculation of Trend and it's definition is:
Average of the last 3 months of the month selected.
If my slicer is selected for example:
Jan/2021 the Average should be from Nov/2020 + Dec/2020 + Jan/2021(Blue selection)
Feb/2021 the Average should be from Dec/2020 + Jan/2021 + Feb/2021 (Orange selection)
My slicer of the month comes from my COD_Calendar table
But my data table has data from 01/2020 till 02/2021
Can anyone please help me with these
Hello @Anonymous ,
To get the average value for the last 3 months (starting from the chosen one in slicer), you'll need to have a proper calendar table (including dates for 2020 and 2021 upon the example) and the next measure:
EDITED upon the next comment
Trend =
IF(HASONEVALUE(Calendar[Date]),
CALCULATE(
AVERAGE(DataTable[Value]),
DATESINPERIOD(
Calendar[Date],
SELECTEDVALUE(Calendar[Date]),
-3, MONTH)
),
AVERAGE(DataTable[Value]))
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
Hi @ERD
Your usage of the time-intel functions is incorrect and will often yield wrong values. Please refer to this guide to understand when you can correctly use them: DATESINPERIOD – DAX Guide. A hint would be: You cannot use time-intel functions with fact tables. You have to have a proper date/calendar table (dimension) to be safe.
Thanks for the hint! Edited previous advise.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
@Anonymous , Try a measure like this with help from date table
Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date ]),-1),-3,MONTH))
User | Count |
---|---|
15 | |
9 | |
8 | |
6 | |
5 |
User | Count |
---|---|
28 | |
18 | |
15 | |
7 | |
6 |