Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
vikasmahajan
Esteemed Contributor

Rank in Script for 3 Fields

Dear All,

I wanted to calculate Rank function for 3 files with Sales Values how to arrive that in attached QVF any Idea?

Thanks in adv

v1.JPG

Message was edited by: vikas mahajan

9 Replies
YoussefBelloum
Esteemed Contributor

Re: Rank in Script for 3 Fields

Hi,

you already calculated the Rank for that Table.

if your files have the same structure, load them all (using * for example) after that Create the Rank like you did on your app.

vikasmahajan
Esteemed Contributor

Re: Rank in Script for 3 Fields

Thanks for reply can you please modify the script ? I am getting incorrect ranks for the same

Vikas

Re: Rank in Script for 3 Fields

What is the expected output?

vikasmahajan
Esteemed Contributor

Re: Rank in Script for 3 Fields

Hi Sunny,

Modified QVF , Actually I have Comp,Prod,State fields as a dimensions and Sale  I wanted to find each company Rank of product sold in state. 

Like   Comp Prod  State  Rank

            A      MS       S1    2

            A       HS      S2   1

            B       HS      S1    3

            B       MS      S1    1

etc..

Vikas

Re: Rank in Script for 3 Fields

What did you modify? I see the same information in the Rank.qvf...

vikasmahajan
Esteemed Contributor

Re: Rank in Script for 3 Fields

I have modify some inline columns please check this imagev1.JPG

Re: Rank in Script for 3 Fields

May be this

INPUT:

LOAD * INLINE [

   COMP,Sale,State,Prd

    A, 14,S1,MS

    B, 22,S2,HS

    C, 9,S3,MS

    A, 9,S4,HS

    B, 5,S4,HS

    C, 3,S3,MS

    A, 5,S1,MS

    B, 9,S2,MS

];


RANK:

LOAD *,

If(State = Peek(State), RangeSum(Peek('Rank'), 1), 1) as Rank

Resident INPUT

order by State, Sale desc;


DROP Table INPUT;

xufei123
Valued Contributor

Re: Rank in Script for 3 Fields

Do you have to do it in script? You can use rank function in the chart like this:

nivethitha
New Contributor II

Re: Rank in Script for 3 Fields

Hi Vikas,

If you require to perform rank option in back end try this,

LOAD   *,

    Autonumber(Sale,Key) as Rank

    Resident test

    Order by Sale desc;

drop table test;

where Key is a composite key of COMP& "Product Group"&STATECODE .

Hope this helps.

Nivethitha.