Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

cumulative total sales by month with nested conditions

Good day, 

I want to build in Qlik Sense a chart that shows cumulative sales. But there are some features because of which I do not understand how to do it:
1. The period does not contain dates, but names of months: M1, M2, M3, ....
2. Also in the data array contains unnecessary information that you want to exclude / filter.

As is:

PeriodProductItemAmount
M1Product_1Item_110
M1Product_1Item_210
M1Product_1Item_310
M1Product_2Item_110
M1Product_2Item_210
M1Product_2Item_310
M2Product_1Item_110
M2Product_1Item_210
M2Product_1Item_310
M2Product_2Item_110
M2Product_2Item_210
M2Product_2Item_310
M3Product_1Item_110
M3Product_1Item_210
M3Product_1Item_310
M3Product_2Item_110
M3Product_2Item_210
M3Product_2Item_310
M4Product_1Item_110
M4Product_1Item_210
M4Product_1Item_310
M4Product_2Item_110
M4Product_2Item_210
M4Product_2Item_310

 

How need:

PeriodProductItemAmount
M1Product_1Item_310
M1Product_2Item_310
M2Product_1Item_320
M2Product_2Item_320
M3Product_1Item_330
M3Product_2Item_330
M4Product_1Item_340
M4Product_2Item_340

 

P.s. RangeSum(Above(SUM(Amount),0,RowNo())) does't work correctly, pls, help.

1 Solution

Accepted Solutions
sunny_talwar

First thing first, I am not sure if your Month field is read as a dual field or not, but in case it doesn't it would make sense to make sure that it is read as a dual field... to do this... you can try like this

LOAD Month(Date#(Period, 'MMM')) as Period

Doing the above will give your Month an underlying numerical value. Jan will be 1, Feb will be 2 and so on...

Once you have this... you can try this

Aggr(RangeSum(Above(Sum({<Item = {"Item_3"}>} Amount), 0, RowNo())), Product, (Period, (NUMERIC)))

View solution in original post

14 Replies
sunny_talwar

You want to only look at Item_3? Also, Period is M1, M2, M3 or Jan, Feb, Mar?
Anonymous
Not applicable
Author

You want to only look at Item_3 - Yes
Period is M1, M2, M3 or Jan, Feb, Mar? -it does not matter
Anonymous
Not applicable
Author

probably better Jan, Feb, Mar,... - so it is more clearly
sunny_talwar

I was not asking if you want Period to be M1, M2, M3 or Jan, Feb, Mar... I was asking what data do you have? Do you have M1, M2, M3 in your data or Jan, Feb, Mar? 🙂
Anonymous
Not applicable
Author

Sorry, 🙂
I have Jan, Feb, Mar, ...
sunny_talwar

First thing first, I am not sure if your Month field is read as a dual field or not, but in case it doesn't it would make sense to make sure that it is read as a dual field... to do this... you can try like this

LOAD Month(Date#(Period, 'MMM')) as Period

Doing the above will give your Month an underlying numerical value. Jan will be 1, Feb will be 2 and so on...

Once you have this... you can try this

Aggr(RangeSum(Above(Sum({<Item = {"Item_3"}>} Amount), 0, RowNo())), Product, (Period, (NUMERIC)))
Anonymous
Not applicable
Author

Not help 😞

screen1.pngscreen2.png

sunny_talwar

Seems strange that Jan is repeating twice...

image.png

I am guessing you understand your data... do you know why the months are repeating?

Anonymous
Not applicable
Author

Thanks, Double data source. Now it works.
But what about the situation if M1, M2,... M12?