Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have a table called dataload_tracking_xto_added with a column called date_released (each row in this table has a date_released value). I would like to add a "yesterday" button and when the user clicks on it all visuals should be filtered to the previous day's date_released. I can use Power BI's relative date filter and just set it to the last 1 day, but this does not handle the case of weekends. If someone checks the dashboard on a Monday or Sunday then the previous day should show Friday's data as there is no data loaded on Saturday or Sunday. I have this query but its not working as expected:
FilterByPreviousBusinessDay =
VAR TodayDate = TODAY()
VAR WeekDay = WEEKDAY(TodayDate , 2)
VAR FilterDate =
IF( WeekDay=1, TodayDate-3, TodayDate -1) -- If today is a Mon then filter to last Friday else filter to previous day
RETURN
IF(SELECTEDVALUE(DATALOAD_TRACKING_XTO_ADDED[DATE_RELEASED] = FilterDate , 1 , 0)
I think the problem here is with the last line "IF(SELECTEDVALUE(DATALOAD_TRACKING_XTO_ADDED[DATE_RELEASED] = FilterDate , 1 , 0)", am I using the correct aggregration function? Should I be doing this in PowerQuery instead of a measure?
If this query worked as expected I would navigate to a page where FilterByPreviousBusinessDay = 1 when the user hits the "yesterday" button.
"Yesterday" and "previous business day" can be very different things. The safest approach is to mark your business days (excluding weekends and holidays) in your calendar table, and then employ the "Penultimate" pattern (prefeably via the new window functions).
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |