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

why does subtracting two time columns not produce a time

  • I have table with two datetime columns for maximum and minimum.  Both have been changed from Datetime to Time  
    jrbrown00_1-1642621651821.png

     

  • I am grouping them by runMonth. 
  • I want the difference between max and min as a time.  My formula looks like this:
    = Table.AddColumn(#"Grouped Rows", "dtDifDuration", each [dtMaxRunDuration] - [dtMinRunDuration])
  • The Power Query Editor decided the format should be numeric (ABC 123) instead of time
    jrbrown00_0-1642621279298.png


  • When I change the type to Time, Power Query tells me it is an error. 
    jrbrown00_2-1642621747078.png

     

Help?

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @jrbrown00 

 

I had done research in this thread as to why the data types are different in the Power Query editor and the model after applying the changes.

Formating a column in Percentage does get applyed in data model

Hope it helps you.

 

 

Best Regards,
Community Support Team _ Zeon Zheng

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

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

Hi, @jrbrown00 

 

I had done research in this thread as to why the data types are different in the Power Query editor and the model after applying the changes.

Formating a column in Percentage does get applyed in data model

Hope it helps you.

 

 

Best Regards,
Community Support Team _ Zeon Zheng

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

v-angzheng-msft
Community Support
Community Support

Hi, @jrbrown00 

Try this:
Time:

= Table.AddColumn(#"Added Custom", "Time", each #time( 
      Duration.Hours([dtDifDuration]), 
      Duration.Minutes([dtDifDuration]), 
      Duration.Seconds([dtDifDuration])))

DateTime:

=Table.AddColumn(
  #"Grouped Rows", 
  "DateTime", 
  each DateTime.From([Date])
    + #duration(
      Duration.Days([dtDifDuration]), 
      Duration.Hours([dtDifDuration]), 
      Duration.Minutes([dtDifDuration]), 
      Duration.Seconds([dtDifDuration])
    )

Please refer to the attachment below for details.

Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

lbendlin
Super User
Super User

subtracting two time values produces a duration, not a time value.

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.