Amazon QuickSight – median
The ‘median’ function in Amazon QuickSight is used to compute the median value of a measure, optionally grouped by one or more dimensions.
Syntax
#Start# median(measure, [group-by level]) #End#
This function takes one argument:
- measure: This parameter specifies the measure for which the median value is to be computed.
- group-by level (optional): This parameter specifies one or more dimensions to group the median calculation.
Suppose we have a dataset that contains information about test scores for students and we want to find the median score by grade level. We can use the median() function in Amazon QuickSight to do this.
To find the median score by grade level, we can create a new visual in Amazon QuickSight and add a table with the following settings:
- Drag the “Grade Level” dimension to the Rows section.
- Drag the “Test Score” measure to the Values section.
- Click on the drop-down arrow next to “Test Score” and select “Median”.
This will result in a table that shows the median test score by grade level.
Alternatively, we can create a calculated field in Amazon QuickSight with the following expression:
Example
#Start# median(TestScore, [GradeLevel]) #End#
This expression will compute the median test score by grade level.
For instance, if our test score data is as follows:
| Student ID | Grade Level | Test Score |
| 1 | 9th | 85 |
| 2 | 10th | 92 |
| 3 | 9th | 76 |
| 4 | 11th | 88 |
| 5 | 10th | 90 |
| 6 | 9th | 82 |
Then, the median test score by grade level will be:
Example
#Start# median(TestScore, [GradeLevel]) = {'9th': 82.5, '10th': 91, '11th': 88} #End#
In this example, we can see that the median() function has computed the median test score by grade level, resulting in a useful metric that can inform our educational decisions.