Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Ceb
Contributor III
Contributor III

Cumulative Sum by Month - QlikSense

Hi,

I am trying to use RangeSum to get cumulative sum of a column by the month. I tried the Aggr function along with the RangeSum function but not able to do so 

This is what I have right now

DateActualYear TargetMonth Target
1/1/2019 0:000184880
1/2/2019 0:004184880
1/3/2019 0:0012184880
1/4/2019 0:0017184880
1/5/2019 0:0017184880
....
....
....
2/1/2019 0:00118184892
2/2/2019 0:00118184892
2/3/2019 0:00118184892
2/4/2019 0:00127184892
2/5/2019 0:00127184892
....
....
....
3/1/2019 0:00217184888
3/2/2019 0:00217184888
3/3/2019 0:00217184888
3/4/2019 0:00223184888
3/5/2019 0:00229184888

 

For the month Target I have 80,92,88 which is individual Month Target but I need to do a vlookup on the month and if new month I need the cumulative sum

I need the following output

DateActualYear TargetMonth Target
1/1/2019 0:000184880
1/2/2019 0:004184880
1/3/2019 0:0012184880
1/4/2019 0:0017184880
1/5/2019 0:0017184880
....
....
....
2/1/2019 0:001181848172
2/2/2019 0:001181848172
2/3/2019 0:001181848172
2/4/2019 0:001271848172
2/5/2019 0:001271848172
....
....
....
3/1/2019 0:002171848260
3/2/2019 0:002171848260
3/3/2019 0:002171848260
3/4/2019 0:002231848260
3/5/2019 0:002291848260

 

Thanks

Labels (3)
1 Solution

Accepted Solutions
sunny_talwar

How about this

RangeSum(Above(If(Day(Date) = 1, Max(Target)/NetWorkDays(MonthStart([Final.dateenrolled]), MonthEnd([Final.dateenrolled])), 0), 0, RowNo()))

 

View solution in original post

5 Replies
StarinieriG
Partner - Specialist
Partner - Specialist

Hi,

try with this expression:

RangeSum(Above(TOTAL Aggr(Max([Month Target]),[Month Target]),0,RowNo(total)))

Ceb
Contributor III
Contributor III
Author

Thanks for the reply StarinieriG!!

 

Not able to get the answer though.

For the monthly target I use the following code.

=floor(Max(Target)/
(networkdays(MonthStart([Final.dateenrolled]) ,MonthEnd([Final.dateenrolled]))))

 

Max(target) - Yearly Target

networkdays(MonthStart([Final.dateenrolled]) ,MonthEnd([Final.dateenrolled]))) - number of working days

 

sunny_talwar

May be this

RangeSum(Above(If(Day(Date) = 1, Sum(DISTINCT [Month Target]), 0), 0, RowNo()))
Ceb
Contributor III
Contributor III
Author

Thanks for the reply Sunny!!

 

In my case instead of [Month Target] I use the following 

Max(Target)/
networkdays(MonthStart([Final.dateenrolled]) ,MonthEnd([Final.dateenrolled]))

 

So implementing your code in mine 

RangeSum(Above(If(Day([Date]) = 1, Sum(DISTINCT

Max(Target)/
networkdays(MonthStart([Date]) ,MonthEnd([Date]))

), 0), 0, RowNo()))

I get an error in expression.

 

Is there an issue using Distinct and Max together?

sunny_talwar

How about this

RangeSum(Above(If(Day(Date) = 1, Max(Target)/NetWorkDays(MonthStart([Final.dateenrolled]), MonthEnd([Final.dateenrolled])), 0), 0, RowNo()))