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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Nicci
Helper I
Helper I

Round hours difference to nearest .25 Help

Hi All,
I am stumped. I have a column that does this:

 

TotalHours = DATEDIFF(HearingsScheduled[StartTime], HearingsScheduled[EndTime], MINUTE) /60
 
This outputs the number of hours between start/end time, output example is this: 0.23, 4.02, 2.95.
 
I want this to be more readable to users as hours and quarter minutes and I have a business rule to round:
 
If it's 7 minutes or more then round up to the nearest .15 increment. So example, if the time is 1.22 that should round to 1.25, but if it was 1.21, that should round to 1.15. another example is if the time is 4.07 it should round to 4.15, but 4.06 should be 4.00.
 
How do I do this from the column I created that gives me the straight difference in minutes / 60 which gives me a decimal number.
 
2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@Nicci 

sometimes you want to roundup, sometimes you want to rounddown. Then you need to use switch to list all the senarios. 

 

pls see the DAX below

 

Column =
var _min=DATEDIFF('Table'[starttime],'Table'[endtime],MINUTE)
var _hour=int(_min/60)
var _min2=mod(_min,60)
var _neaeast = SWITCH(TRUE(),_min2<14,0.15,_min2<28,0.25)
return _hour+_neaeast
 
you can try to update the coding in the SWTICH function to meet your requirement.
 
11.PNG
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Anonymous
Not applicable

Hi @Nicci ,

I create a table and a calculated column as you mentioned.

vyilongmsft_1-1733966516020.png

Then I think you can create another calculated column and use this DAX code.

RoundedHours = 
VAR TotalMinutes = DATEDIFF(HearingsScheduled[StartTime], HearingsScheduled[EndTime], MINUTE)
VAR DecimalHours = TotalMinutes / 60
VAR MinutesPart = MOD(TotalMinutes, 60)
VAR RoundedMinutes = 
    SWITCH(
        TRUE(),
        MinutesPart >= 7 && MinutesPart < 22, 0.25,
        MinutesPart >= 22 && MinutesPart < 37, 0.50,
        MinutesPart >= 37 && MinutesPart < 52, 0.75,
        MinutesPart >= 52, 1,
        0
    )
RETURN
    INT(DecimalHours) + RoundedMinutes

vyilongmsft_2-1733966638229.png

 

 

Best Regards

Yilong Zhou

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Nicci ,

I create a table and a calculated column as you mentioned.

vyilongmsft_1-1733966516020.png

Then I think you can create another calculated column and use this DAX code.

RoundedHours = 
VAR TotalMinutes = DATEDIFF(HearingsScheduled[StartTime], HearingsScheduled[EndTime], MINUTE)
VAR DecimalHours = TotalMinutes / 60
VAR MinutesPart = MOD(TotalMinutes, 60)
VAR RoundedMinutes = 
    SWITCH(
        TRUE(),
        MinutesPart >= 7 && MinutesPart < 22, 0.25,
        MinutesPart >= 22 && MinutesPart < 37, 0.50,
        MinutesPart >= 37 && MinutesPart < 52, 0.75,
        MinutesPart >= 52, 1,
        0
    )
RETURN
    INT(DecimalHours) + RoundedMinutes

vyilongmsft_2-1733966638229.png

 

 

Best Regards

Yilong Zhou

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

ryan_mayu
Super User
Super User

@Nicci 

sometimes you want to roundup, sometimes you want to rounddown. Then you need to use switch to list all the senarios. 

 

pls see the DAX below

 

Column =
var _min=DATEDIFF('Table'[starttime],'Table'[endtime],MINUTE)
var _hour=int(_min/60)
var _min2=mod(_min,60)
var _neaeast = SWITCH(TRUE(),_min2<14,0.15,_min2<28,0.25)
return _hour+_neaeast
 
you can try to update the coding in the SWTICH function to meet your requirement.
 
11.PNG
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors