Forum Discussion
Date diff
We need to verify that if you want to calculate the date difference between the current row and previous row or the date difference between the current row and the first row(ValeusrUtilise=A).
Firstly, add an index column in your table in Query Editor.
Secondly, if you mean the first case, create the following columns in your table.
Previousrow = CALCULATE(FIRSTNONBLANK(Table[DateMoyenne],""),FILTER(Table,Table[Index]=EARLIER(Table[Index])-1))
Datediff = IF(Table[DateMoyenne]<=Table[Previousrow],DATEDIFF(Table[DateMoyenne],Table[Previousrow],DAY)*(-1),DATEDIFF(Table[Previousrow],Table[DateMoyenne],DAY))
If you mean the second case, create the following columns in your table.
first row = CALCULATE(FIRSTNONBLANK(Table[DateMoyenne],""),FILTER(Table,Table[Index]=1))
Datediff2 = IF(Table[DateMoyenne]<=Table[first row],DATEDIFF(Table[DateMoyenne],Table[first row],DAY)*(-1),DATEDIFF(Table[first row],Table[DateMoyenne],DAY))
Regards,
Lydia
- AlexGallet019 years agoHelper IV
- Anonymous8 years agoNot applicable
AlexGallet01,
Where do you store the sample data you post? Do you want to calculate date difference in Power BI Desktop?
Regards,
Lydia- AlexGallet018 years agoHelper IV
The data that I have published are measurements and yes it is on power bi desktop