cancel
Showing results for 
Search instead for 
Did you mean: 

How To Generate Rank with Partitions

vaidyarm
Contributor

Hi

I need to generate the rank for the below data where data should be partitioned by No and Date order by value and want to get the top 3 ranked categories for each No and each Month.

Input :

No Category  Date     Value   Rank
1   Dog     01-01-2022  32  
1   Rabbit  01-01-2022  95  
1   Fish    01-02-2022  4 
1   Ox      01-02-2022  23  
2   Cat     01-01-2022  4 
2   Mouse   01-01-2022  12  
2   Woman   01-02-2022  66  
2   Man     01-02-2022  56  
3   Bird    01-01-2022  54  
3   Bee     01-01-2022  43  
3   Cow     01-02-2022  32  
3   Pig     01-02-2022  89  	

Expected Output :

No Category  Date      Value Rank
1   Rabbit  01-01-2022  95    1
1   Ox      01-02-2022  23    1
1   Dog     01-01-2022  32    2
1   Fish    01-02-2022  4     2
2   Mouse   01-01-2022  12    1
2   Woman   01-02-2022  66    1
2   Cat     01-01-2022  4     2
2   Man     01-02-2022  56    2
3   Bird    01-01-2022  54    1
3   Cow     01-02-2022  32    1
3   Bee     01-01-2022  43    2
3   Pig     01-02-2022  89    2
5 REPLIES 5

viktor_n
Contributor II

Hi @vaidyarm,

Check this pipeline, does the ranks are correct.
012_Community_Answer_2022_05_20.slp (7.8 KB)

will it be applicable if my ranks are not limited to the top 3?

viktor_n
Contributor II

Right now not, but if you remove filter function which is inside the “Set Rank” mapper, it will be.
image

vaidyarm
Contributor

Thought the same, thanks for putting in the effort, appreciate it !!