cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
markefrody
Helper IV
Helper IV

Shift Categories Based on Date and Time

Hi,

 

I have a list of date and time per item. I need to add a calculated column wherein if a time falls between the below ranges they should be classified as follows:
A.) 4:00 AM - 3:59 PM

B,) 4:00 PM - 3:59 AM

Would you be able to help me with a DAX code for this calculated field? Below is an example of how it should like (Column D).
Screenshot.PNG

I am using Direct Query for the data.

Any help is greatly appreciated. Thanks!

 

Best regards, 
Mark V

 

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User III
Super User III

Hi,

This calculated column formula will work

=if(and(mod(Data[Creation date],1)>=time(4,0,0),mod(Data[Creation date],1)<=time(15,59,0)),"4 AM - 3:59 PM","4 PM - 3:59 AM")

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User III
Super User III

Hi,

This calculated column formula will work

=if(and(mod(Data[Creation date],1)>=time(4,0,0),mod(Data[Creation date],1)<=time(15,59,0)),"4 AM - 3:59 PM","4 PM - 3:59 AM")

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Thanks @Ashish_Mathur! Works perfectly!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors