Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator
Creator

Range sum function in expression

Hi All,

I have an expression which is working fine to calculate the cumulative and non cumlative sum of a measure as below

if (SELECTOR1='CUM',

RangeSum(Above(Sum(Documents_Produced), 0,  RowNo())),Sum(Documents_Produced))

Now I just changed the expression to take distinct proc ids while evaluating the document produced which is not working

if (SELECTOR1='CUM',

RangeSum(Above(sum(Count({$<Documents_Produced={'1'}>} distinct PROC_ID), 0,  RowNo())

 

  Sum(Count({$<DATE={'$(vDATE)'},Documents_Produced={'1'}>} distinct  PROC_ID)))

can some one plz help?

4 Replies
Highlighted
Partner
Partner

you can't do sum of count...

change from:

sum(Count({$<Documents_Produced={'1'}>} distinct PROC_ID) )

to:

Count({$<Documents_Produced={'1'}>} distinct PROC_ID)


OR

Sum( Aggr( if( SELECTOR1 = 'CUM',

RangeSum(Above( Count({$<Documents_Produced={'1'}>} distinct PROC_ID), 0,  RowNo() ) ),

Count({$<DATE={'$(vDATE)'},Documents_Produced={'1'}>} distinct  PROC_ID ) ), PROC_ID ) )

Highlighted
MVP
MVP

In general, you need advanced aggregation aggr() function to embed an aggregation function like Count() into another aggregation like Sum().

Highlighted
Creator
Creator

Thanks Andrea! it worked..

Highlighted
Creator
Creator

Thanks for the suggestion Stefan..as of now my expression is working as suggested by Andrea..but its a take way for me which I will need for sure..