Forum Discussion
markus_zhang
7 years agoAdvocate III
DAX: Subtract previous row from current row
Hi Experts, This must be done in a measure, not in a calculated column. I'm working in Excel 2016 not Power BI. I have a sales table qryDump with the following content: (Note there is gap between d...
- 7 years ago
Oh yeah, should have explained that. Yes you can use EARLIER in measures, you would do something like this:
Measure = VAR __index = MAX([Index]) //in visual table context, this is the current index VAR __table = 'Table' VAR __table1 = ADDCOLUMNS(__table,"__diff",[Impressions] - MAXX(FILTER(ALL('Table'),[Index]=EARLIER([Index])-1),[Impressions]) RETURN MAXX(FILTER(__table1,[Index]=__index),[__diff])Something like that, I didn't test it for syntax erros.
Greg_Deckler
2 years agoCommunity Champion
askpbiuser Start a new thread for this question. Post sample data as text and expected output. Tag me in the post.
askpbiuser
2 years agoHelper I
Thank you.
Here is the separate thread - https://community.fabric.microsoft.com/t5/Desktop/DAX-Previous-value-from-measure/td-p/3880390