Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
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 |
---|---|
12 | |
11 | |
8 | |
8 | |
6 |
User | Count |
---|---|
25 | |
19 | |
14 | |
10 | |
7 |