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,
this DAX statement creates a calculated column that determines the value of the previous week.
prevweekvalue =
var currentweek = 'Table1'[week]
var prevweek =
CALCULATE(
MAX('Table1'[week])
,FILTER(ALL('Table1')
,'Table1'[week] < currentweek
)
)
return
LOOKUPVALUE('Table1'[value],Table1[week],prevweek)
If you have any further questions, please start a new thread,, because the question is already answered.
Regards
Tom
Anonymous
8 years agoNot applicable
Sure , this solution doesn't fullfill the cause when I try to extract previous week for 37 it gives 36 instead of 34.
35 and 36 weeks are not availble so when I go for previous week of 37 it should give 34 as previous week.
- TomMartens8 years agoSuper User
Hey, not sure what you are saying, but this looks pretty much reasonable to me:
Regards
Tom