Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello, Im a new Power BI user and i hope someone can help me on this. I need to get the 4 weeks average based on the recent day of the week. Im using a relative date filter showing 4 weeks of data as it needs to be a moving avg. Here is the sample:
For example the most recent date is Tuesday, I want to sum all Tuesdays (315 + 337 + 576 +602) and divide it by 4.
The total will be placed on a card as a part of a Dashboard.
Solved! Go to Solution.
Hi, @atjt217
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create a measure as below.
Result =
var yesterday = TODAY()-1
var _weeday = WEEKDAY(yesterday)
var _weeknum = WEEKNUM(yesterday)
return
CALCULATE(
AVERAGE('Table'[AppCount]),
FILTER(
ALL('Table'),
[Date]<=yesterday&&
[Weeknum]>=_weeknum-3&&
[Weeknum]<=_weeknum&&
[WeekDay]=_weeday
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @atjt217
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create a measure as below.
Result =
var yesterday = TODAY()-1
var _weeday = WEEKDAY(yesterday)
var _weeknum = WEEKNUM(yesterday)
return
CALCULATE(
AVERAGE('Table'[AppCount]),
FILTER(
ALL('Table'),
[Date]<=yesterday&&
[Weeknum]>=_weeknum-3&&
[Weeknum]<=_weeknum&&
[WeekDay]=_weeday
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @atjt217
based on your sample data and your description I get the following solution:
Measure =
VAR _Min = CALCULATE(MIN('Table'[Date]),ALL('Table'[Date]))
VAR _Max = CALCULATE(MAX('Table'[Date]),ALL('Table'[Date]))
RETURN
CALCULATE(
AVERAGE('Table'[ApptCount]),
FILTER(
'Table',
'Table'[Date] >= _Min &&
'Table'[Date] <= _Max &&
'Table'[Weekday] = WEEKDAY(TODAY(),2) // from 1 = Monday to 7 = Sunday
)
)
What you have to keep in mind:
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
99 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
93 | |
84 | |
66 |