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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

TimeDifference with two times

Hi,

 

Could please help with the calculation here?

 

My measure calculation is trying to subtract the times 'sdate' and 'edate' and below should be 2:10 and its displaying as 3:00 on the card.  

 

Is this because Ive used MAX? Ive created another column with the calculation working and displaying 2:10, but I dont know how to reference this in the measure.

 

timediff.PNG

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , the first way to take diff is that you create it as column

 

New column = [Time1] -[time2]


measure options

measure 1 = sumx(Table, Table[Time1] -Table[time2]) //you can use averageX


calculate( min(Table[Time1] ) -max(Table[time2]) , values(Table[ID])) // force row context, but Gt will wrong

 

refer for row context

https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-2-Date-Differ...

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , the first way to take diff is that you create it as column

 

New column = [Time1] -[time2]


measure options

measure 1 = sumx(Table, Table[Time1] -Table[time2]) //you can use averageX


calculate( min(Table[Time1] ) -max(Table[time2]) , values(Table[ID])) // force row context, but Gt will wrong

 

refer for row context

https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-2-Date-Differ...

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak ,

 

Would it still be SUMX with below?

 

IF(SUMX(RoomUtilisation, RoomUtilisation[New End Date]>[ParameterEndDate]),0,1)?

 

Would this be a different operator?

 

Thanks

@Anonymous , what are you try to achieve here ?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak ,

 

I have a couple of If statements 

 

 IF(SUMX(RoomUtilisation, RoomUtilisation[New End Date]>[ParameterEndDate]),1,

IF(SUMX(RoomUtilisation, RoomUtilisation[New End Date]<[ParameterEndDate]),2,

IF(SUMX(RoomUtilisation, RoomUtilisation[New End Date]<= [ParameterEndDate]),3,0

 

It says SUMX cannot work with type Boolean. Ive checked the formatting and all is correct.

Anonymous
Not applicable

Thankyou @amitchandak  as always 🙂

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors