cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Helper IV

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?

2 ACCEPTED SOLUTIONS
Community Champion

@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
Employee

@Kristofferaabo

What does the error message say?

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

Regards,

4 REPLIES 4
Employee

@Kristofferaabo

What does the error message say?

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

Regards,

Community Champion

@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
Helper IV

Perfect! Thanks a lot, it works! 🙂

K

Helper IV

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