Forum Discussion
Date diff
Hello,
I want to do a date diff between datemoyenne of my colum valeursutilisé = B and datemoyenne of my colum valeursutilisé = A.
I need do it for each valeursutilisé.
16 Replies
- AnonymousNot applicable
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- AlexGallet01Helper IV
- AnonymousNot applicable
AlexGallet01,
Where do you store the sample data you post? Do you want to calculate date difference in Power BI Desktop?
Regards,
Lydia