Forum Discussion
Anthony007
8 years agoHelper I
previous week
Help please calculate the difference in company values for each week. There is a table with 4 columns Week Company Value MyRank.1 33 Company A 44 4 33 Company B 44 3 ...
- 8 years ago
Hey,
not sure, but to me thiscalculated column looks like the first solution you were looking for
Column = var prevWeek = LOOKUPVALUE(Table1[Value], 'Table1'[Company],'Table1'[Company],Table1[Week],'Table1'[Week]-1) return IF(ISBLANK(prevWeek),0, 'Table1'[Value] - LOOKUPVALUE(Table1[Value], 'Table1'[Company],'Table1'[Company],Table1[Week],'Table1'[Week]-1))
a screen shot from your sample file
Hope this helps
Tom
TomMartens
8 years agoSuper User
Hey,
not sure, but to me thiscalculated column looks like the first solution you were looking for
Column = var prevWeek = LOOKUPVALUE(Table1[Value], 'Table1'[Company],'Table1'[Company],Table1[Week],'Table1'[Week]-1) return IF(ISBLANK(prevWeek),0, 'Table1'[Value] - LOOKUPVALUE(Table1[Value], 'Table1'[Company],'Table1'[Company],Table1[Week],'Table1'[Week]-1))
a screen shot from your sample file
Hope this helps
Tom
Anonymous
8 years agoNot applicable
what if I have 33,34,38,39 weeks and difference of Table1[value]?
- TomMartens8 years agoSuper User
Hey Anonymous,
Then the DAX would be a little more complex- determine the current weeknumber
- determine the max weeknumber smaller than the current weeknumber
- use both weeknumbers to make the appropriate calculation
I recommend that you start a new question, and please provide sample data.
Regards
Tom