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
midmurali
Helper I
Helper I

Rounding time to nearest quarter

Hey all,

 

I have a table with the following columns:

 

TimeTouch Type
13:00:581
13:06:093
13:06:354
13:06:452
13:09:121

 

And so on. I want to create a column, in which I have the rounded off time to the next quarter if the touch type is 1, and the rounded off time to previous quarter if the touch type is 4. So, ideally the output should be something like this:

 

TimeTouch TypeRounded Off Time
13:00:58113:15:00
13:06:09313:06:09
13:06:35413:06:35
13:06:45213:00:00
13:09:12113:15:00

 

Can someone help me with this? I tried using IF statement in a DAX calculated column but it showed up an error for some reason.

 

Thanks in advance!

M

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@midmurali , I only See changes for 2 and 4

 

a new column =

var _minute = Quotient(minute([Time]),15)

Switch( True() ,

[Touch Type] in {3,4} , [time] ,

[Touch Type]=2 , time(Hour([Time]), _minute *15,  0)

[Touch Type]=4 , if(( _minute +1) <4, time(Hour([Time]), (_minute+1) *15,  0)  , time(Hour([Time])+1, 0,  0) 

) )

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@midmurali , I only See changes for 2 and 4

 

a new column =

var _minute = Quotient(minute([Time]),15)

Switch( True() ,

[Touch Type] in {3,4} , [time] ,

[Touch Type]=2 , time(Hour([Time]), _minute *15,  0)

[Touch Type]=4 , if(( _minute +1) <4, time(Hour([Time]), (_minute+1) *15,  0)  , time(Hour([Time])+1, 0,  0) 

) )

 

Hi Amit, sorry for the typo in my question. The changes are for Touch Types 1 and 2, not 1 and 4 as I originally mentioned.

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.