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
NaddingGod
Frequent Visitor

How do i compare time? power BI desktop

So i have a time column as hh:mm:ss am.  i want to compare this time column with static time values ( shift timings) and to add shifts to my data. M code or Dax funtion works. i cannot figure out how to actually compare time in IF statements. 

 

2 ACCEPTED SOLUTIONS
fhill
Resident Rockstar
Resident Rockstar

One other trick I've used many times is relying on the inherient 'math' of Power BI's native database to my advantage...  

 

Here's an exmaple of a Table with Time and Duration

fhill_0-1626377183382.png

 

Since the fundamental staorage of this data is numeric, you can perform simple math functions against them to get end results...

fhill_1-1626377289937.png

 

Mabye some of your compares can be broken down into > or < simple queries?

Hope this helps...

Forrest

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




View solution in original post

Good catch @fhill , I was thinking duration but it looks like those are actual Times so fundamentally they are stored as decimal numbers with the decimal portion being the fractional day so each hour is stored as 1/24, minute 1/60 and second 1/360.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
fhill
Resident Rockstar
Resident Rockstar

One other trick I've used many times is relying on the inherient 'math' of Power BI's native database to my advantage...  

 

Here's an exmaple of a Table with Time and Duration

fhill_0-1626377183382.png

 

Since the fundamental staorage of this data is numeric, you can perform simple math functions against them to get end results...

fhill_1-1626377289937.png

 

Mabye some of your compares can be broken down into > or < simple queries?

Hope this helps...

Forrest

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Good catch @fhill , I was thinking duration but it looks like those are actual Times so fundamentally they are stored as decimal numbers with the decimal portion being the fractional day so each hour is stored as 1/24, minute 1/60 and second 1/360.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

@NaddingGod - You will need to convert those to seconds, add them and essentially convert them back more or less. Look at the links below, they should get you what you need.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Chelsie-Eiden-s-Duration/m-p/793639#M389
https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486
https://community.powerbi.com/t5/Quick-Measures-Gallery/Duration-to-Seconds-Converter/m-p/342279#M92


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.