Forum Discussion
Cummulative sales figures
Hello,
I am building a sales dashboard using a table SalesInfoPivot with summarized salesfigures per week. I want to add an extra column with cummulative salesfigures for each week. Part of the table looks like this:
Column CummulativeCount should show the sum of [CountThisYearPerWeek]-values for weeks from 1 until [Weeknumber]. In the example I would expect the values 110 - 257 - 434 - 599 - 757 etc.
I am using the following code:
Try adding EARLIER in so that it knows you're referring to the earlier (original) row context rather than the row context from FILTER.
CummulativeCount = CALCULATE ( SUM ( SalesInfoPivot[CountThisYearPerWeek] ), FILTER ( SalesInfoPivot, SalesInfoPivot[WeekNumber] <= EARLIER ( SalesInfoPivot[WeekNumber] ) ) )
4 Replies
- AlexisOlsonSuper User
Try adding EARLIER in so that it knows you're referring to the earlier (original) row context rather than the row context from FILTER.
CummulativeCount = CALCULATE ( SUM ( SalesInfoPivot[CountThisYearPerWeek] ), FILTER ( SalesInfoPivot, SalesInfoPivot[WeekNumber] <= EARLIER ( SalesInfoPivot[WeekNumber] ) ) )- AlbertJanFrequent Visitor
Thank you, Alexis. You made my day!
- amitchandakSuper User
AlbertJan , Try
CummulativeCount = CALCULATE(
SUM( SalesInfoPivot[CountThisYearPerWeek] ),
FILTER(allselected(SalesInfoPivot),
SalesInfoPivot[WeekNumber] <= [WeekNumber]))or
CummulativeCount = CALCULATE(
SUM( SalesInfoPivot[CountThisYearPerWeek] ),
FILTER(all(SalesInfoPivot),
SalesInfoPivot[WeekNumber] <= [WeekNumber]))- AlbertJanFrequent Visitor
Thanks for yor reply. Unfortunately this does not solve the problems. Rows are not filtered.