Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Rangesum not working

Hello!

I'm having an issue with using rangesum in the script. Attached is an XLS extract of sample data and in column D I specified desired outcome.

When I use a single sales day my formula works and calculated rangesum works without a problem. However, when I add more days to my dataset, that is when rangesum gets out of whack.

I use:

if(Date= peek('Date', -1), rangesum(Sales, peek('RangeSum'))) as RangeSum

Any idea what I am doing wrong here? Data needs to be arranged from highest sales to lowest, by day.

Thanks!

15 Replies
Not applicable
Author

Hi Deepak,

My main sort criteria are Date and Sales. Sales needs to be sorted in a descending order and for the very last Sales record my AccSum must equal total range sum of Sales for that date.

M

IAMDV
Master II
Master II

Hi Marko,

"My main sort criteria are Date and Sales. Sales needs to be sorted in a descending order and for the very last Sales record my AccSum must equal total range sum of Sales for that date".

Please can you provide sample data of end result in excel for sub set of data. I'm not following completely...sorry!

Cheers,

DV

Not applicable
Author

Hi Deepak,

I attached qvw in my previous post and created a straight table that will give you data sorted as necessary. If you select 20131109 and export to XLS, do sum of the Sale column and you will get -881.447

I hope this helps.

M

jagan
Partner - Champion III
Partner - Champion III

Hi Marko,

In straight table sort the data by Accumulated Sum and you will get the last row as -881.447 which is equal to the Sum of all Sales values.  Please check attached file.

Regards,

Jagan.

Not applicable
Author

Your answer is in the right direction. The only problem I have now is that my keys that have 0 for sales do not get accumulated.

I also moved the logic from the script to a chart with rangesum(above(sum(..)),0,rowno())) expression.

If i didn't have randonm blanks in my table this would definitely be the correct answer.

Thank you.

Not applicable
Author

Hi Jagan,

That won't work. I cannot sort by AccSum column as the requirement is to sort primarily by sales figures.

Thanks,

M