Qlik Community

Qlik DataMarket Discussions

Discussion Board for collaboration regarding Qlik DataMarket.

Highlighted
divyanshi
New Contributor III

I want to calculate top accounts and that should change with filter selection

Hi All,

I have one filter named Customer Selection which has two values as Customer Group as well as Customer Name.

I am calculating top accounts by using this:

if(aggr(rank((sum(profit))),[Customer Name])<=10,[Customer Name ]))

My requirement is on selecting Customer Name, it will select top accounts from Customer Name and

if I am select Customer Group ,it will select top accounts from Customer Group.


I am doing this by:


if(getfieldselection(Customer Selection)='Customer Name',



if(aggr(rank((sum(profit))),

[Customer Name])<=10,[Customer Name ]))

,

if(aggr(rank((sum(profit))),

[Customer Group])<=10,[Customer Group ]))

)

Tags (2)
1 Solution

Accepted Solutions

Re: I want to calculate top accounts and that should change with filter selection

Try something like this

=Aggr(If(Rank(Sum(Revenue)) <= 2, $(='[' & If(GetFieldSelections([Customer Selection]) = 'Customer Name', 'Customer Name', 'Customer Group Descr') & ']')),

$(='[' & If(GetFieldSelections([Customer Selection]) = 'Customer Name', 'Customer Name', 'Customer Group Descr') & ']'))

Tested based on the sample provided here

Grouping by two fields within same table

View solution in original post

5 Replies
divyanshi
New Contributor III

Re: I want to calculate top accounts and that should change with filter selection

But I am not able to get the required data.

Kindly help.

Re: I want to calculate top accounts and that should change with filter selection

Try something like this

=Aggr(If(Rank(Sum(Revenue)) <= 2, $(='[' & If(GetFieldSelections([Customer Selection]) = 'Customer Name', 'Customer Name', 'Customer Group Descr') & ']')),

$(='[' & If(GetFieldSelections([Customer Selection]) = 'Customer Name', 'Customer Name', 'Customer Group Descr') & ']'))

Tested based on the sample provided here

Grouping by two fields within same table

View solution in original post

divyanshi
New Contributor III

Re: I want to calculate top accounts and that should change with filter selection

Ok Thanks....But along with this, I want top customers should change on Trend(YoY & QoQ) selection also.

That means top customers should work on Customer Selection as well as on Trend selection.

Kindly help.

divyanshi
New Contributor III

Re: I want to calculate top accounts and that should change with filter selection

Hi Sunny,

PFA of the qvf file,  I want when someone selects QoQ in Trend it gives me rank according to recent quarter revenue-previous quarter revenue, when the user selects YoY in trend ranking is done with respect to recent year quarter- previous year quarter.

Appreciate your help

Re: I want to calculate top accounts and that should change with filter selection

First of all, which object are we looking at? What needs to change when you select Trend? and to what value? Can you elaborate?