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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
AdamD123
Helper I
Helper I

Subtract Number of Days

Hello,

 

I am trying to find out the number of days difference between two dates. I thought this would be a fairly easy subtraction but I seem to be struggling due to the dates coming from different data sets. I have looked through previous queries but they all appear to be from the same dataset.

AdamD123_1-1718024367626.png

 

 

I would like to subtract the order date from the posting date, so for example the top one will show as 1 day. 'Order_date' is from one dataset and 'Posting_date' is from another.

 

Can anyone advise please?

 

Kind regards,

Adam

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@AdamD123 

maybe you can try this

 

datediff(max(orderdate),max(postingdate),day)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Hi Ryan,

 

This seems to have worked, thank you ever so much!

 

AdamD123_0-1718097126902.png

 

View solution in original post

9 REPLIES 9
ryan_mayu
Super User
Super User

@AdamD123 

maybe you can try this

 

datediff(max(orderdate),max(postingdate),day)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi Ryan,

 

This seems to have worked, thank you ever so much!

 

AdamD123_0-1718097126902.png

 

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




lucadelicio
Super User
Super User

Can you prepare and upload a pbix example with a fake data but the same model?

Thank you



Luca D'Elicio

LinkedIn Profile

I wouldn't know how to do this sorry.

lucadelicio
Super User
Super User

Hi @AdamD123 ,

you have to create a CALCULATED COLUMN using DIFFDATE() function.
Refer to this documentation:
https://learn.microsoft.com/en-us/dax/datediff-function-dax

Try to use this calculated column formulas.
Column =
DATEDIFF([Order_Date], [Posting_Date], DAY)

Mark as a solution if i help you to resolv your problem



Luca D'Elicio

LinkedIn Profile

Hello Luca,

Thank you for your reply. I have done this but get the below:

AdamD123_0-1718025271365.png

 

You have to respect the syntax of the code!
Helping with intellisense that suggest you the wright way, put the table name before the comun name.
Something like this:
DATEDIFF(Tablename[Order_Date], Tablename[Posting_Date], DAY)



Luca D'Elicio

LinkedIn Profile

I think I understand what you are explaining but that is the issue, the one column does not appear to select because they are from different date sets:

AdamD123_1-1718027219745.png

AdamD123_2-1718027256969.png

 

 

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.