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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Duration type and logical comparison to a fixed value.

Plese excuse my newbie question. 

I am trying to get power query to be able to do an IF  THEN ELSE using the comaprison of a duration field to a fixed value - if duration is greater than 6 hours, yes else no.   I have tried 

Add Column -> Custom Column -> If [duration column] > "0.05.00.00" then "yes" else "no"   The 0.05:00:00  I what I am guessing would be 5 hours  for the fixed value. Am I even close?

2 ACCEPTED SOLUTIONS
mahoneypat
Microsoft Employee
Microsoft Employee

Assuming your [duration colum] has a duration data type, you need to use this syntax to hard code a duration value

 

if [duration column] > #duration(0,5,0,0) then "yes" else "no"

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Anonymous
Not applicable

Hi @Anonymous ,

 

I think you can take a look at bleow links which about duration.

 

Reference:

Function Description
Duration.Days Returns the day component of a Duration value.
Duration.From Returns a duration value from a value.
Duration.FromText Returns a Duration value from a text value.
Duration.Hours Returns an hour component of a Duration value.
Duration.Minutes Returns a minute component of a Duration value.
Duration.Seconds Returns a second component of a Duration value.
Duration.ToRecord Returns a record with parts of a Duration value.
Duration.TotalDays Returns the total magnitude of days from a Duration value.
Duration.TotalHours Returns the total magnitude of hours from a Duration value.
Duration.TotalMinutes Returns the total magnitude of minutes from a Duration value.
Duration.TotalSeconds Returns the total magnitude of seconds from a duration value.

 

For instance:

Duration.Second([Datetime Column]) //get the second value(0~59) of datetime

Duration.TotalSeconds([Datetime Column]) //convert datetime value to second

 

Sample: get the diff of date range and convert them to second.

16.PNG17.PNG

 

Best Regards,

Stephen Tao

 

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

 

I think you can take a look at bleow links which about duration.

 

Reference:

Function Description
Duration.Days Returns the day component of a Duration value.
Duration.From Returns a duration value from a value.
Duration.FromText Returns a Duration value from a text value.
Duration.Hours Returns an hour component of a Duration value.
Duration.Minutes Returns a minute component of a Duration value.
Duration.Seconds Returns a second component of a Duration value.
Duration.ToRecord Returns a record with parts of a Duration value.
Duration.TotalDays Returns the total magnitude of days from a Duration value.
Duration.TotalHours Returns the total magnitude of hours from a Duration value.
Duration.TotalMinutes Returns the total magnitude of minutes from a Duration value.
Duration.TotalSeconds Returns the total magnitude of seconds from a duration value.

 

For instance:

Duration.Second([Datetime Column]) //get the second value(0~59) of datetime

Duration.TotalSeconds([Datetime Column]) //convert datetime value to second

 

Sample: get the diff of date range and convert them to second.

16.PNG17.PNG

 

Best Regards,

Stephen Tao

 

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

mahoneypat
Microsoft Employee
Microsoft Employee

Assuming your [duration colum] has a duration data type, you need to use this syntax to hard code a duration value

 

if [duration column] > #duration(0,5,0,0) then "yes" else "no"

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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