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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

New Measure

Hey guys, my given "Laikas" ( Time) below is in whole number format and I cant figure out new measure to return difference if the time exceeds 4:30 norm and if does not exceed 4:30 then return simply 00:00:00. Any ideas?

 

 

 

Gediminas12_0-1600410371268.png

 

 

 

 

7 REPLIES 7
amitchandak
Super User
Super User

@Anonymous , The information you have provided is not making the problem clear to me. Can you please explain with an example.

 

You can compare time in Column  like

if([Laikas] >=time(4,30,0))

 

or measure like

if(max([Laikas]) >=time(4,30,0))

 

How to deal with duration -https://radacad.com/calculate-duration-in-days-hours-minutes-and-seconds-dynamically-in-power-bi-using-dax


Appreciate your Kudos.


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

@amitchandak 

Yes, that's part of the measure, so I want to say that if Laikas(Time) exceeds 04:30:00 then return the difference between overtime and 04:30:00

@Anonymous , Evening 4 would be 16.

Row context will play role in answer

 

Try like

if(max([Laikas]) >=time(4,30,0) , max([Laikas]) - time(4,30,0) , 0 )

if(max([Laikas]) >=time(4,30,0) , max([Laikas]) - time(16,30,0) , 0 )

or

if(max([Laikas]) >=time(4,30,0) , datediff(max([Laikas]), time(4,30,0),minute) , 0 )
if(max([Laikas]) >=time(4,30,0) , datediff(max([Laikas]), time(16,30,0),minute) , 0 )

 

and a sum like

sumx(Values(Table[Indeksas]), if(max([Laikas]) >=time(4,30,0) , datediff(max([Laikas]), time(16,30,0),minute) , 0 ))

 

or

sumx(Values(Table[Indeksas]), if(([Laikas]) >=time(4,30,0) , datediff(([Laikas]), time(16,30,0),minute) , 0 ))

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

@amitchandak 

It still doesn't work, this is my following table.  first column is time in the whole number format and then second one is norm that should not be exceeded, if it exceeds this norm, then return the difference(Third column) between the two, but if it does not exceed 04:30 then return 00:00:00.

 

Gediminas12_0-1600412176354.png

 

 

@Anonymous , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

@amitchandak 

That's all i have at the moment. So basically first column you see with the time values, but in format as a whole number. Second column should be the drive time norm that should not be exceeded. Now the third column should do the following: If first column(klaipėda - radviliškis) exceeds second column value, then we should return the difference between the two(actual first column and second column). If first column value does not exceed second column, then we should just return actual time in the first column. 

Gediminas12_0-1600412176354.png

 

 

Hi @Anonymous ,

 


@Anonymous wrote:

@amitchandak 

That's all i have at the moment. So basically first column you see with the time values, but in format as a whole number. Second column should be the drive time norm that should not be exceeded. Now the third column should do the following: If first column(klaipėda - radviliškis) exceeds second column value, then we should return the difference between the two(actual first column and second column). If first column value does not exceed second column, then we should just return actual time in the first column. 

Gediminas12_0-1600412176354.png

 

 


Sorry, I don't quite understand that. Could you share a sample pbix to let us know more about the scenario.(Please mask any sensitive data before uploading)

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.