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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Deepesh153
Frequent Visitor

Unable to subtract two columns in the power query

I was trying to subtract two columns with date/time, time datatype on the power query but I selected the desired columns the Date , Time options on the Add Columns Section gets disabled . I don't know what is happening here if anyone can help please Screenshot 2024-10-12 193313.png

 I am on the september version 

1 ACCEPTED SOLUTION
Omid_Motamedise
Memorable Member
Memorable Member

In such situation, there are several useuful function.

If you want to calculate the difference of just houre or minute part if two Date.Time use
Duration.Minutes
Duration.Hours
Duration,Second


But if you want to calculate total differnce in hours or minute use
Duration.TotalHours
Duration.TotalMinutes

View solution in original post

5 REPLIES 5
Omid_Motamedise
Memorable Member
Memorable Member

In such situation, there are several useuful function.

If you want to calculate the difference of just houre or minute part if two Date.Time use
Duration.Minutes
Duration.Hours
Duration,Second


But if you want to calculate total differnce in hours or minute use
Duration.TotalHours
Duration.TotalMinutes

Deepesh153
Frequent Visitor

https://drive.google.com/file/d/10voipz3SMxxKmPu5CMRXYRUVpL2IJsb4/view?usp=drivesdkvideo I don't understand what your are saying but if go to the advanced editor and write the code I am trying to do ,it works 

watkinnc
Super User
Super User

The result of datetime minus datetime is a duration type value. That's why you no longer see the datetime tools. If you want the result to be 12:47:05 AM, then you need to use Duration.TotalDays (not Duration.Days) and then Time.From. So

 

= Table.AddColumn(PriorStepOrTableName, "Time",  each Time.From(Duration.TotalDays[Subtraction])))

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
Omid_Motamedise
Memorable Member
Memorable Member

Use 

Duration.Days

If this answer helped resolve your issue, please consider marking it as the accepted answer. And if you found my response helpful, I'd appreciate it if you could give me kudos. Thank you!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.