I have created a DAX for 7 day rolling average as -
Solved! Go to Solution.
Hi @monikamishra ,
Would you please add a weekday column in date table:
WEEKDAY = WEEKDAY(Dim_Date[Date],2)
Then try to use the following measure:
OR Cases 7 Day Rolling Average =
VAR A =
CALCULATE (
MAX ( 'Dim_Date'[Date] ),
FILTER (
ALL ( Dim_Date ),
Dim_Date[Date] <= MAX ( Dim_Date[Date] )
&& Dim_Date[WEEKDAY] > 6
)
)
VAR NUM =
MAX ( Dim_Date[Date] ) - A + 1
VAR TOTALVALUE =
CALCULATE (
[OR Cases (Total)],
FILTER (
ALL ( Dim_Date ),
Dim_Date[Date] >= A
&& Dim_Date[Date] <= MAX ( Dim_Date[Date] )
)
)
RETURN
TOTALVALUE / NUM
You can also refer to the sample pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/Ef5zxVgk6VBOqAeN5s...
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Hi @monikamishra ,
Would you please add a weekday column in date table:
WEEKDAY = WEEKDAY(Dim_Date[Date],2)
Then try to use the following measure:
OR Cases 7 Day Rolling Average =
VAR A =
CALCULATE (
MAX ( 'Dim_Date'[Date] ),
FILTER (
ALL ( Dim_Date ),
Dim_Date[Date] <= MAX ( Dim_Date[Date] )
&& Dim_Date[WEEKDAY] > 6
)
)
VAR NUM =
MAX ( Dim_Date[Date] ) - A + 1
VAR TOTALVALUE =
CALCULATE (
[OR Cases (Total)],
FILTER (
ALL ( Dim_Date ),
Dim_Date[Date] >= A
&& Dim_Date[Date] <= MAX ( Dim_Date[Date] )
)
)
RETURN
TOTALVALUE / NUM
You can also refer to the sample pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/Ef5zxVgk6VBOqAeN5s...
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Do you always want Sun-Sat? Then you'll need to use WeekNumber. Add WeekNumber to your DimDate table if you don't have it in there already.
Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos.
I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query.
@monikamishra , Think you need last Week , please check my blog
Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
or try like example
//Last seven till week end
last week =
Week Start date = maxx(allselected('Date'),'Date'[Date])+-7
Week End date = maxx(allselected('Date'),'Date'[Date])+-+ 7-1*WEEKDAY('Date'[Date],2) //sunday is week end
return
CALCULATE(SUM(Sales[Net Sales]),FILTER(all('Date'),'Date'[Date]>=_min && 'Date'[Date]<=_max))
//use WEEKDAY('Date'[Date],1) for saturday
Proud to be a Super User!
Featured Session: Drive Data Culture with Power BI- Vision, Strategy & Roadmap. Register here https://myignite.microsoft.com #MSIgnite #PowerPlatform #Power BI
Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!
User | Count |
---|---|
466 | |
183 | |
118 | |
61 | |
52 |
User | Count |
---|---|
445 | |
166 | |
129 | |
76 | |
73 |