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

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

@Anonymous , 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) 

) )

 

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

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , 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) 

) )

 

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 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
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.