cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Spencer_J
Frequent Visitor

2-Day Custom Time Range for Visual

Hello!

 

I am trying to include data in a bar graph that spans 2 days. Within this data, it is divided into 2 shifts. Let's call them 1 and 2. This data contains time stamps for each line item of data. I want to create a page for the 2nd shift which spans from 4pm to 2am. The issue I am running into, is including the previous days data. For example, if right now it's 1am, I want to include all data from 4:30pm from previous day until 1am right now. But, if it's 11pm, I only want to include 4pm-11pm in the graph. I have tried date filters, but seeing difficulty with data needed across 2 days. 

 

In my data, the time stamp can be whole hour or full date time stamp. I have a custom column for 1-24 (hours) and a full time stamp column. 

 

Any help would be greatly appreciated! 

 

Thank you!

3 REPLIES 3
Spencer_J
Frequent Visitor

Hi Amit, I had this exact formula and the issue I am having is it's adding the previous days same shift to my current day. So now, my visual for 'today' is not adding the previous days line items if it's after midnight. If that doesn't make sense, let me know and I can make an example file in Power BI. 

 

Thank you!

Spencer

amitchandak
Super User
Super User

@Spencer_J , In such case I prefer to move date example

 

if(timevalue([DateTime])<time(4,0,0) , datevalue([Datetime]) -1, datevalue([Datetime]) )

 

this will force same date for any time before 4 AM as 2PM - Shift start date



Learn Power BI - Full Course with Dec-2022, with new DAX functions like Window, Index, Offset !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Formatted Profit and Loss Statement with empty lines

Here's another example. Let's just say we want a visual to total the amount for this shift. Currently summing the amount but it's summing from the same shift but the day before. 

 

DateHourAmount
13-Dec7100
13-Dec8200
13-Dec9300
13-Dec10400
13-Dec11200
13-Dec12600
14-Dec1800
14-Dec2400

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.