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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
inglexjc
Post Patron
Post Patron

Date Difference between 2 columns same table.

I'm trying to show the date difference between 2 columns in the same table.  Exampe I'm wanting to show how many days between "Initial Ruling Date" and "Final Ruling Date"

Initial Ruling DateFinal Ruling Final Ruling Date
6/5/2025Dismissed6/30/2025
4/14/2025Dismissed5/12/2025
6/30/2025Dismissed7/17/2025
4/15/2025Dismissed5/9/2025
3/26/2025Dismissed4/14/2025
6/13/2025Dismissed7/7/2025
3/11/2025Dismissed4/25/2025
4/24/2025Dismissed5/16/2025
3/28/2025Dismissed4/15/2025
3/31/2025Dismissed4/15/2025
2/12/2025Dismissed2/27/2025
4/24/2025Dismissed5/16/2025
1 ACCEPTED SOLUTION
MarkLaf
Super User
Super User

Add a custom column and use Duration.TotalDays, like:

 

Duration.TotalDays( [Final Ruling Date] - [Initial Ruling Date] )

 

When doing addition with dates, you'll get a duration as an output. This function converts that duration to # days.

 

Output would look like the following. Note that if the initial or final date are null, then the custom column will also be null. I added nulls to your initial data to show this.

 

MarkLaf_0-1753995597694.png

 

View solution in original post

6 REPLIES 6
Omid_Motamedise
Super User
Super User

Hi @inglexjc 

the issue came from the format of your date, but using the "en-US") Culture can easily solve the problem.

just copy the following code and paste it into the advanced editor to see how 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZAxCsAgDEXvklmIiUbbvbcQt3Zw6OT9oUKhKkToFsLL/09TgoCCbFnAwFHqXWq9zjYHdPbdZ5PAI3mNEiTuVL+ZqYgUpyy1UXDvkEMOGtRF3kJyemEco4j0KJbRilcvDJPWttCSkXKLxpHi7+9mqi3jfy/I+QE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Initial Ruling Date" = _t, #"Final Ruling " = _t, #"Final Ruling Date" = _t]),
    #"Lowercased Text" = Table.TransformColumns(Source,{{"Final Ruling Date", each Date.FromText(_, "en-US"), type date},{"Initial Ruling Date", each Date.FromText(_, "en-US"), type date}}),
    #"Added Custom" = Table.AddColumn(#"Lowercased Text", "Custom", each Duration.Days([Final Ruling Date]-[Initial Ruling Date]))
in
    #"Added Custom"

 

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
v-lgarikapat
Community Support
Community Support

Hi @inglexjc ,

Thanks for reaching out to the Microsoft fabric community forum.

@MarkLaf , @MasonMA 

Thanks for your prompt response

@inglexjc

Another workaround to achieve this is by using Power Query, where you can simply select the two date columns and subtract one from the other to calculate the difference.

I have uploaded the file for your review. Please let us know if you need any assistance or modifications  we’re happy to help.

 

 

vlgarikapat_2-1754024073874.png

vlgarikapat_3-1754024110401.png

 

We truly appreciate your continued engagement and thank you for being an active and valued member of the community.

If you're still experiencing any challenges, please don’t hesitate to reach out  we’d be more than happy to assist you further.

We look forward to hearing from you.

Best regards,
Lakshmi

 

MarkLaf
Super User
Super User

Add a custom column and use Duration.TotalDays, like:

 

Duration.TotalDays( [Final Ruling Date] - [Initial Ruling Date] )

 

When doing addition with dates, you'll get a duration as an output. This function converts that duration to # days.

 

Output would look like the following. Note that if the initial or final date are null, then the custom column will also be null. I added nulls to your initial data to show this.

 

MarkLaf_0-1753995597694.png

 

Duration.TotalDays is returning decimal number that includes fractional days.

 

Would there be a reason to use this function for two columns that only contain dates? 

 

When only dealing with dates, then Duration.TotalDays and Duration.Days provide the same result. Perhaps there is a (probably infinitesimal) performance edge with using Duration.Days?

 

I went with Duration.TotalDays as it is more precise when dealing with datetimes, so it's more general purpose.

 

E.g.,

Duration.Days( #duration(0,23,59,59) ) = 0 

VS  

Duration.TotalDays( #duration(0,23,59,59) ) = 0.99998842592592585

MasonMA
Memorable Member
Memorable Member

Hello @inglexjc 

 

If you wanted to calculate this in Power BI with DAX, create a column with below DAX

 

DATEDIFF(
'Table'[Initial Ruling Date],
'Table'[Final Ruling Date],
DAY
)


Or, if you are on Import mode and would like to have them calculated during data load, in Power Query, Add one Custom Column with below M code:

 

Duration.Days([Final Ruling Date] - [Initial Ruling Date])

 

This will also create a new column showing the difference in days.

 

Hope this helps:) 

 

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