Forum Discussion
Anonymous
4 years agoNot applicable
Dates Between calculation based on previous row
Hi team, I need help with a DatesBetween DAX calculation. I have data coming from two tables: Table 1: CodeKey CodeNum 1 PM033 2 PM034 3 ...
- 4 years ago
Hi,
Please check the below picture and the attached pbix file.
Days between measure: = VAR currentcode = MAX ( Table1[CodeKey] ) VAR currentdate = MAX ( Table2[Date] ) VAR previousdate = MAXX ( FILTER ( ALL ( Table2 ), Table2[CodeKey] = currentcode && Table2[Date] < currentdate ), Table2[Date] ) RETURN IF ( HASONEVALUE ( Table1[CodeKey] ), INT ( currentdate - previousdate ) * DIVIDE ( previousdate, previousdate ) )
Anonymous
4 years agoNot applicable
Hi Jihwan_Kim ,
Thank you very much! This works perfectly. One more question, regarding the first row of my data, what should I add to the calculation in order the first row for 2022 to take the previous date from 2021?
Best,
Emma