Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi everyone.
I am struggling abit with this running average.
Measure =
CALCULATE(
DIVIDE((SUM('Sheet1'[Aqua])*358),(sum('sheet1'[Wlk3]))),
FILTER(
ALLSELECTED('Sheet1'[Date]),
ISONORAFTER('Sheet1'[Date], MAX('Sheet1'[Date]), DESC)
)
)
It works really good, but I only want the calculation starting last year from MAX.
Since I have data from 3-4 years ago, which would not be relevant for me.
Is there a way to start the calculation from exactly 1 year ago?
Thank you so much in advance! 😀
Let me know if there is any other data I should show.
Solved! Go to Solution.
Hi @Astro1990 ,
As far as I know, DATESINPERIOD() will work if you have continuous date in your data model. So if there is continuous date in Sheet1, you will get correct result. You can add a dimdate table by CALENDAR() or CALENDARAUTO() with continuous date as well.
I think you can achieve your goal with Filter() function as well. Try this code.
Measure =
VAR _LASTDATE = MAXX(ALL(Sheet1),Sheet1[Date])
RETURN
CALCULATE(
DIVIDE((SUM('Sheet1'[Aqua])*358),(sum('sheet1'[Wlk3]))),
FILTER(
Sheet1,
Sheet1[Date] > EOMONTH(_LASTDATE,-12)
)
)
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you so much Rico!
It worked wonderfully!
I think I corrected it. Instead of Filter, I used DatesinPeriod.
It looks great! Still checking if it, so I'll post here once I finished checking.
FILTER(
ALLSELECTED('Sheet1'[Date]),
ISONORAFTER('Sheet1'[Date], MAX('Sheet1'[Date]), DESC)
)
)
To the following:
Hi @Astro1990 ,
As far as I know, DATESINPERIOD() will work if you have continuous date in your data model. So if there is continuous date in Sheet1, you will get correct result. You can add a dimdate table by CALENDAR() or CALENDARAUTO() with continuous date as well.
I think you can achieve your goal with Filter() function as well. Try this code.
Measure =
VAR _LASTDATE = MAXX(ALL(Sheet1),Sheet1[Date])
RETURN
CALCULATE(
DIVIDE((SUM('Sheet1'[Aqua])*358),(sum('sheet1'[Wlk3]))),
FILTER(
Sheet1,
Sheet1[Date] > EOMONTH(_LASTDATE,-12)
)
)
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
82 | |
81 | |
52 | |
39 | |
35 |
User | Count |
---|---|
95 | |
79 | |
52 | |
49 | |
47 |