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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Coelijoeli
Advocate I
Advocate I

Calculate date difference

Hello Community,

 

I am looking for a way to find the difference between two dates.

 

I tried te following example: Date1 - Date2

This does not give me the difference... this gives me a weird date value.

 

I tried to use DATEDIFF, but it does not work because Date 2 can have a lower date then date 1.

 

What are other options I can use?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Coelijoeli

There was just a recent thread on this. Depending on what you need to do there are several solutions.

 

Thread

 

My quick solution:

diff = 1.0*([Closed]-[TransactionDate])

 

 

View solution in original post

3 REPLIES 3
SamsonAnalytics
Frequent Visitor

Use this code in a new column:

_DateDiferrence =
VAR
Sum_Date=Calculate(sumx('TableName','TableName'[DATE1]-'TableName'[DATE2]))
RETURN
if(sum_Date>=0,Sum_Date,0)
 
I hope it works for you
Anonymous
Not applicable

hi @SamsonAnalytics 

how would this look if you want to calculate the average for eg products?


and how would this look if the dates are on two different columns?

thank you in advance,

Niki

Anonymous
Not applicable

@Coelijoeli

There was just a recent thread on this. Depending on what you need to do there are several solutions.

 

Thread

 

My quick solution:

diff = 1.0*([Closed]-[TransactionDate])

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.