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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Incuseg
New Member

DAX

I need help with this dax, when I substract two times and one of them is higher than the other one, it gives me a negative result. How can I resolve this problem?

Incuseg_0-1673449906843.png

 

Here is the Dax Im using rigth now but is not working correctly, I dont know if I have to use the If(). The problem is I dont how to use it in my current Dax.

Incuseg_1-1673449994701.png

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Incuseg , In date diff, first use smaller value .

 

else we need to adjust for day end

 

if([End Time] < [Start Time], datediff([End Time]+1, [Start Time], second) ,datediff([End Time], [Start Time], second) )

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

3 REPLIES 3
FreemanZ
Super User
Super User

hi @Incuseg 

try to wrap with ABS, like
ABS( DATEDIFF(... ) )

amitchandak
Super User
Super User

@Incuseg , In date diff, first use smaller value .

 

else we need to adjust for day end

 

if([End Time] < [Start Time], datediff([End Time]+1, [Start Time], second) ,datediff([End Time], [Start Time], second) )

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

Thank you very much for your help, but now I have another problem. When I added new information, it gives me the result of the seconds in negative when it should be positive. How can i solve this?

Incuseg_0-1673453759287.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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