Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
villasenorbritt
Resolver I
Resolver I

Excluding Time Frames in Visual when Populating Values with a Measure and Rows with Time Bins

I have a measure that is taking seconds, which corresponds with downtime for a specific machine, and turns it into a duration. 

Here is the measure :

Chelsie Eiden's Duration =
// Duration formatting
// * @konstatinos 1/25/2016
// * Given a number of seconds, returns a format of "hh:mm:ss"
//
// We start with a duration in number of seconds
VAR Duration = SUM([actualdowntime])
// There are 3,600 seconds in an hour
VAR Hours = INT ( Duration / 3600)
// There are 60 seconds in a minute
VAR Minutes = INT ( MOD( Duration - ( Hours * 3600 ),3600 ) / 60)
// Remaining seconds are the remainder of the seconds divided by 60 after subtracting out the hours
VAR Seconds = ROUNDUP(MOD ( MOD( Duration - ( Hours * 3600 ),3600 ), 60 ),0) // We round up here to get a whole number
Var FinalDuration = Hours * 10000 + Minutes * 100 + Seconds
RETURN
// We put the hours, minutes and seconds into the proper "place"
//Hours * 10000 + Minutes * 100 + Seconds
FinalDuration
 
I'm using TimeBins as well in my visual. So I have the ShiftDate, 60_Min_Bins, and 15_Min_Bins in the Rows section of matrix and then the production and downtime in the values:

villasenorbritt_1-1679077409886.png

I wrote a calculated column I was wanting to use as a filter since break and lunch times should not be counted towards downtime:

Exclude_Time_Period = IF(
(vwDowntime[Time] >= TIME(8,30,0) && vwDowntime[Time] <= TIME(8,45,0)) && vwDowntime[Shift] = "1st Shift" ||
(vwDowntime[Time] >= TIME(11,0,0) && vwDowntime[Time] <= TIME(11,30,0)) && vwDowntime[Shift] = "1st Shift" ||
(vwDowntime[Time] >= TIME(14,0,0) && vwDowntime[Time] <= TIME(14,15,0)) && vwDowntime[Shift] = "1st Shift" ||
(vwDowntime[Time] >= TIME(23,30,0) && vwDowntime[Time] <= TIME(24,00,0)) && vwDowntime[Shift] = "2nd Shift" ||
(vwDowntime[Time] >= TIME(21,00,0) && vwDowntime[Time] <= TIME(21,15,0)) && vwDowntime[Shift] = "2nd Shift" ||
(vwDowntime[Time] >= TIME(2,30,0) && vwDowntime[Time] <= TIME(2,45,0)) && vwDowntime[Shift] = "2nd Shift" ||
(vwDowntime[Time] >= TIME(17,00,0) && vwDowntime[Time] <= TIME(17,30,0)) && vwDowntime[Shift] = "3nd Shift" ||
(vwDowntime[Time] >= TIME(14,00,0) && vwDowntime[Time] <= TIME(14,15,0)) && vwDowntime[Shift] = "3nd Shift" ||
(vwDowntime[Time] >= TIME(20,00,0) && vwDowntime[Time] <= TIME(20,15,0)) && vwDowntime[Shift] = "3nd Shift" ||
(vwDowntime[Time] >= TIME(22,30,0) && vwDowntime[Time] <= TIME(22,45,0)) && vwDowntime[Shift] = "3nd Shift"
,
TRUE(),
FALSE()
)
 
 
I tried putting this into the Filters pane and selecting False but the times I'm wanting to exclude still show up. I tried adjusting the Exclusion column to the time bins  and not just my regular time column, and even tried adding it into the duration measure, but nothing is working. Any tips?
1 ACCEPTED SOLUTION

Phew.  Create a calendar table that goes down to that level (ie 48 rows per day) and then based your measures on that new calendar table, using EXCEPT and INTERSECT.

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

what's the biggest bin size you can get away with for this?  half hour slots? 15 minute slots? 5 minutes?

Half hour slots is the biggest bin size I can get away with for this. 

Phew.  Create a calendar table that goes down to that level (ie 48 rows per day) and then based your measures on that new calendar table, using EXCEPT and INTERSECT.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.