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: 
ninawang99
Contributor
Contributor

Alternate states in expression

Hi Community,

My dataset is like below:

Year Month Volume
2022 Jan 56471
2022 Feb 55007
2022 Mar 57326
2022 Apr 57699
2022 May 60444
2022 Jun 57500
2022 Jul 53942
2022 Aug 63657
2022 Sep 56893
2022 Oct 64409
2022 Nov 63278
2022 Dec 58469

 

I would like to use range sum to check the rolling number, while when use the rangesum() function with Alternate State, the results are not accurate,

my expression is  rangesum( sum({$*[Year 1]} Volume)), where [Year 1] is my alternate state name, and results are showed as below, correct results also be listed,

Year Month Volume rangesum( sum({$*[Year 1]} Volume)) Correct Results
2022 Jan 56471 56471 56471
2022 Feb 55007 55007 111478
2022 Mar 57326 57326 168804
2022 Apr 57699 57699 226503
2022 May 60444 60444 286947
2022 Jun 57500 57500 344447
2022 Jul 53942 53942 398389
2022 Aug 63657 63657 462046
2022 Sep 56893 56893 518939
2022 Oct 64409 64409 583348
2022 Nov 63278 63278 646626
2022 Dec 58469 58469 705095

 

Is there any thing I need to change in my expression? 

Thanks in advance

 

 

Labels (2)
8 Replies
SunilChauhan
Champion II
Champion II

May try this.

RangeSum(above(sum({$*[Year 1]} Volume) ,0,rowno()))

Sunil Chauhan
ninawang99
Contributor
Contributor
Author

Hi Iam,

The volume column was calculated by sum({$*[Year 1]} Volume), and after I tried the expression you provided, the results are same.

ninawang99_0-1686897644617.png

 

Regards,

 

 

 

 

SunilChauhan
Champion II
Champion II

RangeSum(above(sum({$*[Year]} Volume) ,0,rowno()))

Sunil Chauhan
ninawang99
Contributor
Contributor
Author

all results are displayed as 0

SunilChauhan
Champion II
Champion II

 Simple try this RangeSum(above(sum( Volume) ,0,rowno(Total))) and tell why you need {$*[Year]. i think work without this also

Sunil Chauhan
NiTo
Creator
Creator

Hi,

Try this:

RangeSum(above(Total sum(Volume) ,0,rowno(Total)))

 

tresesco
MVP
MVP

Check this:

RangeSum(above(sum({$*[Year 1]} Volume) ,0,rowno(total)))

tresesco_0-1686899803880.png

 

 

ali_hijazi
Partner - Master II
Partner - Master II

Hello @ninawang99 
I assume you want to presever the cumulative number per month after you select a specified month no?
if this is the case then your expression would look something like this:
=RangeSum(
Sum([Volume]),
Above(Sum({<[Month]>}[Volume]))
)
*
Avg(1)

I can walk on water when it freezes