Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Guys,
If created an expression that gives me the expected accumateled sales starting 2011. (see screenshot). What this expression does is: sum(Sales) of a year + the sum(Sales) over the previous years.
example:
11.684 + 16.442 = 28.126 (2012) expected accumalted sales in 2012
28.126 + 24.340 = 52.466 (2013) expected accumalted sales in 2013
I 'Solved' this using the following expression:
if(Year=2011,
sum(Sales) ,
if(Year=2012,
sum(Sales) + before((sum(Sales) ),1),
if(Year=2013,
sum(Sales) + before((sum(Sales) ),1) + before((sum(Sales) ),2),
if(Year=2014,
sum(Sales) + before((sum(Sales) ),1) + before((sum(Sales) ),2) + before((sum(Sales) ),3),
if(Year=2015,
sum(Sales) + before((sum(Sales) ),1) + before((sum(Sales) ),2) + before((sum(Sales) ),3) + before((sum(Sales) ),4),
if(Year=2016,
sum(Sales) + before((sum(Sales) ),1) + before((sum(Sales) ),2) + before((sum(Sales) ),3) + before((sum(Sales) ),4)
+ before((sum(Sales) ),5)
))))))
As you can see there's just to many if statments, which makes it to difficult to manage if another year is added.
My 2 questions are:
I've attached a qlikview sample.
Thanks in advance!
Carter
Ok, try this then: RangeSum(Before(sum(Sales),0,ColumnNo()))
If you hadn't made a crosstable, the field year would not be text. It would then be a lot simpler to calculate the cummulative sales over years. See attached example
Hi Gysbert,
Thanks for your help! The 'problem' with your solution is that you have to create an expression for each year. If my dimension would have 10 years or more I need to create at least 10 expression.
I've formated the field year from text to year.
Cheers
Carter
Ok, try this then: RangeSum(Before(sum(Sales),0,ColumnNo()))
Cool!!! Thanks Gysbert! Which I knew about the rangesum function. Learned something new today