Forum Discussion
Filtering previous workweek on a Power BI page
For those who are interested in filtering the previous workweek on a Power BI page, you can create a measure called IsPrevWorkWeek using the following DAX formula:
IsPrevWorkWeek =
VAR prev_monday =
TODAY ()
- ( WEEKDAY ( TODAY (), 2 ) + 6 )
VAR prev_sunday =
TODAY () - WEEKDAY ( TODAY (), 2 )
VAR datesrange =
CALENDAR ( prev_monday, prev_sunday )
RETURN
IF ( SELECTEDVALUE ( 'date'[Date] ) IN datesrange, 1, 0 )You can then use this measure as a filter on the visuals you want to filter for the previous workweek by adding it with a value that equals 1. The advantage of this approach is that the measure isn’t affected by any filter context and calculates itself on report interaction, so isn’t relying on data refresh. The only thing to note is that the visual needs to have the date in a row or axis.
I hope this helps!
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.