Forum Discussion

benji1908's avatar
benji1908
Frequent Visitor
3 years ago

Dynamic time range filter that switches based on current time

I'm a bit of an amatuer at Power BI, generally looking at DAX and such from other peoples solutions and applying it to my own needs but this is something I can't seem to find.

I'm currently making a production report that works off a live feed SQL server. The idea is that it will take production numbers from a monitoring system in place and present it as an hourly visual as an aid. The system provides the figures by date and breaks that down by hour. 

E.g.

 

01/01/2023 ¦ 07:00 ¦ 1000
01/01/2023 ¦ 08:00 ¦ 900
01/01/2023 ¦ 09:00 ¦ 1100

 

When I publish the report, it's going to a different region, and as a result it's a day behind, so I can't use a relative date filter. Even if I filter it by date, but then the transition over 00:00 makes the front end on night shift vanish and I want to have the complete shift on there. 

Because of these issues, I've made a table that has times (with a sort and day/night shift control column) that pulls the production data for the last time listed on the system, thus bypassing the date issue as I always want to look at the most recent hours. 

The issue I'm having is I want to show 7am-7pm for day shift and 7pm-7am for the night shift. Ideally it will filter seperately, so when the time goes past 7pm it will clear away all the day shift data and count nights 7pm-7am, and likewise at 7am it changes back to the day shift and shows data from 7am-7pm. 

I thought it would be relatively simple with a formula containing time(now etc. and a set criteria, but I just can't seem to wrap my head around it.