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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
refint650
Helper III
Helper III

difference between two date fileds

Hello All

how to calcualte difference of days between two dates from two tables, Also what happenes if source columns values are expected nulls  how to handle this in logic.

 

Salesdate - sales table

Orderdate - order table

 

date diff( salesdate, orderdate, days)..?

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @refint650 

Thanks for reaching out to us.

First, you need to find the dates you want to compare from the two tables, and then use the datediff function.

for example, 

measure= 

var _date1= minx(filter(table1,table1[column1]="xxx"), [Salesdate])

var _date2= minx(filter(table2,table2[column1]="xxx"), [Orderdate])

return datediff(_date1,_date2,day)

 

Best Regards,

Community Support Team _Tang

If this post helps, 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-xiaotang
Community Support
Community Support

Hi @refint650 

Thanks for reaching out to us.

First, you need to find the dates you want to compare from the two tables, and then use the datediff function.

for example, 

measure= 

var _date1= minx(filter(table1,table1[column1]="xxx"), [Salesdate])

var _date2= minx(filter(table2,table2[column1]="xxx"), [Orderdate])

return datediff(_date1,_date2,day)

 

Best Regards,

Community Support Team _Tang

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

amitchandak
Super User
Super User

@refint650 , You need a common dimension joined to both tables

 

Sumx(Values(Order[Order]) , datediff( Min(sales[salesdate], max(Order[orderdate], days) )

 

same as this one

https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-2-Date-Differ...

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  

 

without agreagate function  alternate way to find difference of date columns from two tables.?

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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