How can the median be calculated in Power BI, and can you provide an example?

Power BI is a powerful data analysis and visualization tool that allows users to easily calculate and analyze various statistical measures, including the median. The median is a measure of central tendency that represents the middle value in a dataset. To calculate the median in Power BI, one can use the MEDIAN function in the DAX (Data Analysis Expressions) language. This function takes a column or a table as its input and returns the median value. For example, if we have a dataset with the values 1, 2, 3, 4, 5, the median would be 3. To calculate this in Power BI, we can use the formula “MEDIAN([Column])” and the result would be 3. This allows users to easily calculate the median for any dataset in Power BI, making it a valuable tool for data analysis.

Calculate Median in Power BI (With Example)


You can use the following syntax in DAX to calculate the median value in a column:

Median Points = MEDIAN('my_data'[Points])

This particular example creates a new measure named Median Points that calculates the median value in the Points column of the table named my_data.

The following example shows how to calculate the median value of a column in Power BI in practice.

Example: How to Calculate Median in Power BI

Suppose we have the following table in Power BI named my_data that contains information about points scored by basketball players on various teams:

Suppose we would like to calculate the median value in the Points column.

To do so, click the Table tools tab along the top ribbon, then click the New measure icon:

Then type in the following formula into the formula bar:

Median Points = MEDIAN('my_data'[Points]) 

This will create a new measure named Median Points that contains the median of values in the Points column of the table:

If we’d like, we can display this value by going to the Report View in Power BI, then by clicking the Card icon under the Visualizations tab, then by dragging the Median Points measure under the Fields label:

This will produce the following card that displays the median value in the Points column of the table:

We can see that the median value in the Points column is 19.

If we click on any of the individual names in the Team column of the table in the report, then the card will automatically update to show the median points value for that particular team.

For example, suppose we click the Rockets team name in the table:

The card automatically updates to show that the median of values in the Points column for the Rockets is 24.

Additional Resources

The following tutorials explain how to perform other common tasks in Power BI:

x