2.16 Grouping: calculate median

 

Calculate the median salary in each department based on the following salary table.

ID NAME DEPT SALARY
1 Rebecca R&D 7000
2 Ashley Finance 11000
3 Rachel Sales 9000
4 Emily HR 7000
5 Ashley R&D 16000

SPL script:

A
1 =T(“salary.xlsx”)
2 =A1.groups(DEPT;median(,SALARY):MedianSalary)

Execution result:

DEPT MedianSalary
Administration 9500.0
Finance 7000.0
HR 7000
Marketing 7000
Production 6500