๐ Ranking Function (HGrid247)
๐ Definition
Ranking is a function to rank data that has been:
- Grouped (GroupBy)
- Sorted (ascending / descending)
โก๏ธ Rank is determined based on the sorting result field
โ๏ธ Parameter
๐ฏ Max Rank
- Determine the maximum limit of the resulting ranking
- Only data with:
rank โค Max Rank
which will be passed on to the next assembly
๐ If not filled in:
โก๏ธ All data remains out (unrestricted)
๐ฅ Input & ๐ค Output
Input
-
All fields from the previous process (usually the result of GroupBy + Sort)
Output
-
All input fields
โ additional new fields:
ranking
๐ง How it works
For example, the data is already sorted:
category views
---------------------
A 90
A 100
A 80
โก๏ธ After Ranking:
category views ranking
--------------------------
A 100 1
A 90 2
A 80 3
๐งช Case Example (Top N per Group)
๐ฏ Case Study:
Displays the Top 2 videos with the most views per category
๐ Workflow
- Group By โ category
- Sort โ views DESC
- Ranking (Max Rank = 2)
๐ Results:
category video views ranking
-----------------------------------
Music V1 1000 1
Music V2 900 2
Music V3 800 โ (not out)
๐ฅ Important Insights
1. Ranking requires sorting
Without sorting:
โก๏ธ ranking becomes meaningless
2. Used for Top-N
Common use cases:
- Top 10 best-selling products
- Top 5 video trending
- Top customer per region