Top N Sum


๐Ÿ“Š Top N Sum Function

๐Ÿ” Definition

This function is used to:

โžก๏ธ Sum the values โ€‹โ€‹of a field
โžก๏ธ Then take the N data with the largest total value

In other words:
    Aggregate + Automatic Ranking (Top N based on SUM)

โš™๏ธ Parameter

1. ๐ŸŽฏ Field

Fields to be summed

Example:

2. ๐Ÿ”ข Number of Record (N)

3. ๐Ÿ”€ Ordered (Y/N)

๐Ÿ“Œ Recommendation: use Y for clear results (Largest top)

๐Ÿ“ฅ Input & ๐Ÿ“ค Output

Input Output
The output will contain:

๐Ÿง  How it works

For example data:
    category        views
    ---------------------
    Music           100
    Music           200
    Gaming          300
    Gaming          100
After the process:
1. SUM per category
    category        sum_views
    --------------------------
    Music           300
    Gaming          400
2. Top N (for example N=1)
    category_new    sum_views
    -------------------------
    Gaming          400

๐Ÿงช Case Study Examples

๐ŸŽฏ Case:

Displays the Top 3 YouTube categories with the most total views

๐Ÿ”„ Workflow ๐Ÿ“Š Output:
    category_new	sum_views
    -----------------------------
    Music               1,000,000
    Gaming              900,000
    News                850,000

๐Ÿ’ก Important Note:

The useful output fields from this buffer function are the grouped fields and new fields. Add a Transformator () assembly afterward to select these fields.