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.
good day,
I am working on a report where I have to calculate the rolling 25 days average using the market share. I used the quick measures to calculate my 25 days average and when I do a manual test in calculating, I found out that my formula does not take the past 25 working days, it counts 25 days including weekends. Can someone help with how to exclude weekends?
the formula used is
Solved! Go to Solution.
@Anonymous ,
Firstly, create a calendar table using calendar() function, create relationship between the calendar table and your orginal table using date field.
Secondly,create the following columns in your calendar table.
WeekDay = WEEKDAY('Calendar'[Date])
If work day = IF(OR('Calendar'[WeekDay]=1,'Calendar'[WeekDay]=7),0,1)
At last, create the following measure in your original table.
25 day MA = VAR WorkingDays = FILTER( CALCULATETABLE( Calendar, DATESINPERIOD( 'Calendar'[Date], LASTDATE( 'Calendar'[Date] ), -25, DAY) ), 'Calendar'[If work day]= 1 ) RETURN AVERAGEX( WorkingDays, [Market Share] + 0 )
Regards,
Lydia
@Anonymous ,
Firstly, create a calendar table using calendar() function, create relationship between the calendar table and your orginal table using date field.
Secondly,create the following columns in your calendar table.
WeekDay = WEEKDAY('Calendar'[Date])
If work day = IF(OR('Calendar'[WeekDay]=1,'Calendar'[WeekDay]=7),0,1)
At last, create the following measure in your original table.
25 day MA = VAR WorkingDays = FILTER( CALCULATETABLE( Calendar, DATESINPERIOD( 'Calendar'[Date], LASTDATE( 'Calendar'[Date] ), -25, DAY) ), 'Calendar'[If work day]= 1 ) RETURN AVERAGEX( WorkingDays, [Market Share] + 0 )
Regards,
Lydia
I have implemented the solution in my case and still gives out an incorrect answer. Can I send you a link to my pbix file maybe you can see what I am talking about?
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 |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |