cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted

How to calculate days/months between to date columns

Hi, I have to columns of dates and with the new aggreagted option in the Jan 17 version of powerBI iI was hoping to see some 'levels' in the dates. Especially the time between the First date in column X and the last date in column Y.

 

Im however struggeling to calcualte the days (months preferebly) between the two columns below ('earlist FPI and Latest LPI'). I have tried the datediff but it returns errors..

 

Any ideas?

 

powerBI question.png

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Vvelarde Super Contributor
Super Contributor

Re: How to calculate days/months between to date columns

@Kristofferaabo

 

Hello, try with these measures

 

Diff in Days=
DATEDIFF ( FIRSTDATE ( Table2[Date] ), LASTDATE ( Table2[Date] ), DAY )
Diff in Months=
DATEDIFF ( FIRSTDATE ( Table2[Date] ), LASTDATE ( Table2[Date] ),MONTH )



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

Proud to be a Datanaut!




Moderator v-sihou-msft
Moderator

Re: How to calculate days/months between to date columns

@Kristofferaabo

 

What does the error message say?

 

Make sure those two columns are data type, it supposes to work when using DATEDIFF() function.

 

4.PNG

 

55.PNG

 

Regards,

4 REPLIES 4
Vvelarde Super Contributor
Super Contributor

Re: How to calculate days/months between to date columns

@Kristofferaabo

 

Hello, try with these measures

 

Diff in Days=
DATEDIFF ( FIRSTDATE ( Table2[Date] ), LASTDATE ( Table2[Date] ), DAY )
Diff in Months=
DATEDIFF ( FIRSTDATE ( Table2[Date] ), LASTDATE ( Table2[Date] ),MONTH )



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

Proud to be a Datanaut!




Moderator v-sihou-msft
Moderator

Re: How to calculate days/months between to date columns

@Kristofferaabo

 

What does the error message say?

 

Make sure those two columns are data type, it supposes to work when using DATEDIFF() function.

 

4.PNG

 

55.PNG

 

Regards,

Re: How to calculate days/months between to date columns

Perfect! Thanks a lot, it works! Smiley Happy

K

 

 

Re: How to calculate days/months between to date columns

Another poblem I have is that it will not work if I have some empty cells in the columns.

Can I somehow account not to calculate with where there is blank cells? 

 

Kristoffer

Helpful resources

Announcements
Community Highlights

Community Highlights

Find out what's new in the Power BI Community!

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 306 members 3,327 guests