Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us at the Cloud Data and Analytics Tour! REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
eddysunn
Contributor III
Contributor III

Aggr() and if()

Hi Everyone,

I am trying to build a bar chart with defined dimensions. The dimensions are defined by =valuelist('Top','Rest') , and the measures should be presented as the sum of Invoice Amounts of top 5 performers and sum of Invoice Amounts of the rest.

I tried to define this as the script shown below. For the 'Top' part I am getting a correct value, but the second part is showing empty.

if( valuelist('Top','Rest')='Top',

sum(aggr(  IF( aggr ( Rank(sum([Invoice Amount])),[Customer Name])<=5,

sum([Invoice Amount])),[Customer Name])),

sum(aggr(  IF( aggr ( Rank(sum([Invoice Amount])),[Customer Name])>5,

sum([Invoice Amount] )),[Customer Name]))

)


Could anyone help me out with how to follow from here on?

Thanks!

Edil

1 Solution

Accepted Solutions
3 Replies
Not applicable

Hi Try This,

if( valuelist('Top','Rest')='Top',
IF( aggr ( Rank(sum([Invoice Amount])),[Customer Name])<=5,sum([Invoice Amount])),[Customer Name])),

IF( aggr ( Rank(sum(
[Invoice Amount])),[Customer Name])>5, sum([Invoice Amount] )),[Customer Name])))

pls correct the syntax if i am wrong   else could u pls share your application

eddysunn
Contributor III
Contributor III
Author

Thanks Sunny T,

So instead of using a Synthetic Dimension (i.e =valuelist('Top','Rest')), which turned out to be tricky to work together with when using Aggr() function, I chose a simpler way. Which is:

Dimension:

if( aggr ( Rank(sum([Invoice Amount])),[Customer Name])<=5,  'Top', 'Rest');

Measure:

sum([Invoice Amount])

This easily does the thing I need.

I think I just overthought the difficulty of the project.