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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AI14
Helper III
Helper III

if statement time based

Hi

 

Is there a formula to compare 2 times if less than or more than a fixed time for example,

 

Actual 09:59

Target 10:00

 

if Actual is less than Target by 10 mins then 1 if not 0

 

 

4 REPLIES 4
BrianConnelly
Resolver III
Resolver III

For this we will convert your time to DateTime using the TimeValue and then calculate minutes using DateDiff.

DATEDIFF (TIMEVALUE(time_text) ,TIMEVALUE(time_text) ,MINUTE)

 

Then build your switch statement or if statement for the logic.  Many ways to do this, but here are a few...

SWITCH(TRUE()
,DATEDIFF (TIMEVALUE(time_text) ,TIMEVALUE(time_text) ,MINUTE) > 10, 1
,0)

 

IF(DATEDIFF (TIMEVALUE(time_text) ,TIMEVALUE(time_text) ,MINUTE)>10,1,0)

 

tamerj1
Super User
Super User

Hi @AI14 

IF ( DATEDIFF ( 'Table[Actual]'Table[Target], MINUTE ) = 10, 1, 0 )

Thanks,

 

Would i need to add a < to say if its less than?

@AI14 

I believe it should be difference > 10

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors