MEDIAN

How to Use the Power BI DAX function MEDIAN

What is the MEDIAN function?

The MEDIAN function in Power BI is a DAX function that calculates the median value of a given dataset. The median is the middle value in a set of numbers, and it is a useful statistic for understanding the central tendency of a dataset because it is not affected by outlier values.

How does the MEDIAN function work?

The MEDIAN function works by taking an input dataset as an argument and returning the median value of that dataset. The syntax for the MEDIAN function is as follows:


MEDIAN(❰column❱)


Where `❰column❱` is the name of the column or expression that contains the values you want to calculate the median for.

Using the MEDIAN function in Power BI

To use the MEDIAN function in Power BI, you must have a dataset with a column or expression that contains the values you want to calculate the median for. Once you have your dataset loaded into Power BI, follow these steps:

1. Create a new measure by navigating to the "Modeling" tab in the ribbon and clicking on "New Measure."

2. In the formula bar that appears, enter the following formula:


Median Value = MEDIAN(❰column❱)


Replace `❰column❱` with the name of the column or expression that contains the values you want to calculate the median for.

3. Click "Enter" to create the measure.

You can now use your new measure in your Power BI visualizations to display the median value of your dataset.

Examples of using the MEDIAN function in Power BI

Here are a few examples of how you can use the MEDIAN function in Power BI:

Example 1: Calculating the median sales value by region

Suppose you have a dataset that contains sales data for a company, and you want to calculate the median sales value by region. Here's how you can do it:

1. Load your dataset into Power BI and navigate to the "Modeling" tab in the ribbon.

2. Click on "New Measure" in the ribbon to create a new measure.

3. In the formula bar, enter the following formula:


Median Sales by Region = MEDIAN(Sales[Value])


This formula calculates the median sales value for the "Value" column in the "Sales" table.

4. Click "Enter" to create the measure.

5. Add a table or chart to your report and drag the "Region" column into the Rows field and the "Median Sales by Region" measure into the Values field.

6. Power BI will display a table or chart that shows the median sales value by region.

Example 2: Visualizing the median salary by job title

Suppose you have a dataset that contains employee data, including job titles and salaries, and you want to visualize the median salary by job title. Here's how you can do it:

1. Load your dataset into Power BI and navigate to the "Modeling" tab in the ribbon.

2. Click on "New Measure" in the ribbon to create a new measure.

3. In the formula bar, enter the following formula:


Median Salary by Job Title = MEDIAN(Employee[Salary])


This formula calculates the median salary for the "Salary" column in the "Employee" table.

4. Click "Enter" to create the measure.

5. Add a table or chart to your report and drag the "Job Title" column into the Rows field and the "Median Salary by Job Title" measure into the Values field.

6. Power BI will display a table or chart that shows the median salary by job title.

The MEDIAN function in Power BI is a powerful tool for quickly calculating the median value of a dataset. By following the steps outlined in this article, you can easily create measures that use the MEDIAN function and incorporate them into your Power BI reports. Whether you are analyzing sales data, employee data, or any other type of data, the MEDIAN function can help you gain valuable insights into the central tendency of your dataset.

Power BI DAX Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)