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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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
Super User
Super User

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

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h

View solution in original post

5 REPLIES 5
Omid_Motamedise
Super User
Super User

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

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
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 

Anonymous
Not applicable

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

Omid_Motamedise
Super User
Super User

Use 

Duration.Days

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h

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!

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors