Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
vikasmahajan

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

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
9 Replies
YoussefBelloum
Champion
Champion

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
Author

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

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
sunny_talwar

What is the expected output?

vikasmahajan
Author

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

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
sunny_talwar

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

vikasmahajan
Author

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

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
sunny_talwar

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;

NZFei
Partner - Specialist
Partner - Specialist

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

nivethitha
Partner - Contributor II
Partner - Contributor II

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.