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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
morther
Helper I
Helper I

datediff formula with multiple criteria not pulling proper data

I am trying to create a column that pulls downtime minutes between 2 dates excluding hours or non-ooperation 9PM to 5AM.  If the downtime minutes fall between the exclude hours they should probably be set to 0.  This is what I have so far on the formula but much of the results are incorrect.

 

WorkingDowntimeMinutes =
IF (
    (
        EventLog[startdatetime] >= HOUR ( 5 )
            || EventLog[StartTime] <= HOUR ( 21 )
    )
        && (
            EventLog[stopdatetime] >= HOUR ( 5 )
                || EventLog[stopdatetime] <= HOUR ( 21 )
        ),
    DATEDIFF ( EventLog[startdatetime], EventLog[stopdatetime], MINUTE )
)

Any ideas where I am going wrong and how to add an else for the 0?

 

Thanks,

Mike

 

 

1 ACCEPTED SOLUTION

I got this from Experts-Exchange and it worked.

IF (  HOUR(EventLog[startdatetime]) >=  5 , EventLog[DowntimeMinutes], 0 )

View solution in original post

2 REPLIES 2
morther
Helper I
Helper I

Okay, I am really not understanding this.  I made this a bit simpler but still no proper results.

test =
IF ( EventLog[startdatetime] >= HOUR ( 5 ), EventLog[DowntimeMinutes], 0 )

If I set ">=" then I get DownTimeMinutes but no "0" results.  If i change to "<="  then I get all "0" but no DownTimeMinutes

 

results.JPG

I would expect the hilighted row to show "0" because the time is before 5 AM.

 

I got this from Experts-Exchange and it worked.

IF (  HOUR(EventLog[startdatetime]) >=  5 , EventLog[DowntimeMinutes], 0 )

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors