DAX (Data Analysis Expression) functions in Power BI help in the creation of calculated columns, complex calculations, and measures. It aids powerful data manipulation, visualization, and analysis. That will, in turn, lead to effective decision-making.
One of the complex calculations you can perform using DAX functions is the DAX median. This guide will help you figure out how to find out median, why you should calculate the median in Power BI, and the advantages of calculating the median DAX.
First…
Definition: The MEDIAN function in DAX calculates the median value of a set of numbers. It’s the middle value in a sorted list of numbers, or the average of the two middle values if the list has an even number of elements.
In DAX, the MEDIAN function is used to calculate the median of a dataset. The formula syntax is:
The function returns the median value of the specified column. For instance:
Definition: The median in Power BI represents the middle value of a dataset when arranged in ascending or descending order. It calculates the (median) value for a given column and provides insights into the central tendency of a data distribution.
The median provides a robust measure of central tendency that is less influenced by outliers compared to the mean. That comes in handy when dealing with Power BI datasets that contain extreme (or skewed) values.
It’s also used in conjunction with other statistical measures to provide a comprehensive understanding of the characteristics of your dataset.
You can find the median using the MEDIAN function within a calculated column or measure. Here’s how to do just that.
Navigate to the dataset in Power BI Desktop, and go to the “Modeling” tab in the ribbon. Next, click on “New Column” in the Calculations group. Enter the formula using the MEDIAN function, and reference the column for which you want to calculate the median. For instance:
MedianColumn = MEDIAN(’Table’[Column])
To create the calculated column, press “Enter.”
Navigate to the dataset in Power BI Desktop, and go to the “Modeling” tab in the ribbon. Next, click on “New Measure” in the Calculations group. Enter the formula using the MEDIAN function, and reference the column for which you want to calculate the median in Power BI. For instance:
MedianMeasure = MEDIAN(’Table’[Column])
From the image above, you can see the total sales for each customer. All you needed to do was add a visual to the report canvas (1 below), add the calculated column (2), and set the aggregation to MEDIAN (3).
From the image above, the answer is 270.27. The issue with this approach is that you’ll have to write a calculated column to get the answer. Yes, there is a time and place for a calculated column, but you don’t need to create a calculated column to get this answer.
The calculated column above is conceptually easy for anyone to understand. It’s easy to write. You can solve the problem one step at a time. You can see the interim results, and anyone with an Excel background can do it with very little understanding of DAX. Understanding the MEDIANX function is much harder. It’s harder until you realize that MEDIANX is doing the exact thing as this calculated column.
Here’s the MEDIANX formula.
Median Customer Sales Measure = MEDIANX(Customers,[Total Sales]).
Stage 1: Logging in to Power BI
Application Channels | Initial Screening | Conduct Interviews | Employee Onboarding |
Total Candidates
|
Social Media | Short Listed | Final Interview | Hired | 32 |
Social Media | Short Listed | Final Interview | Not Hired | 400 |
Social Media | Short Listed | Knocked Out | 800 | |
Social Media | Knocked Out | 1100 | ||
Company Career Page | Short Listed | Final Interview | Hired | 20 |
Company Career Page | Short Listed | Final Interview | Not Hired | 250 |
Company Career Page | Short Listed | Knocked Out | 500 | |
Company Career Page | Knocked Out | 900 | ||
Events | Short Listed | Final Interview | Hired | 5 |
Events | Short Listed | Final Interview | Not Hired | 100 |
Events | Short Listed | Knocked Out | 200 | |
Events | Knocked Out | 350 | ||
Paper Media | Short Listed | Final Interview | Hired | 3 |
Paper Media | Short Listed | Final Interview | Not Hired | 80 |
Paper Media | Short Listed | Knocked Out | 135 | |
Paper Media | Knocked Out | 700 | ||
Employee Referrals | Short Listed | Final Interview | Hired | 10 |
Employee Referrals | Short Listed | Final Interview | Not Hired | 70 |
Employee Referrals | Short Listed | Knocked Out | 80 | |
Employee Referrals | Knocked Out | 110 | ||
Direct | Short Listed | Final Interview | Hired | 25 |
Direct | Short Listed | Final Interview | Not Hired | 150 |
Direct | Short Listed | Knocked Out | 425 | |
Direct | Knocked Out | 600 |
The DAX function for calculating the median in Power BI is MEDIAN().
Yes, in Power BI and DAX, the function for calculating the median is MEDIAN(). It computes the median value of a column (or expression) in a dataset.
To insert a median function in Power BI, use the formula MEDIAN(). After that, use the column or expression you want to calculate the median within the formula.
DAX median calculates the middle value of a dataset. It helps in the robust analysis of data. With the DAX median, you can get a reliable measure of central tendency less influenced by outliers, and that aids in accurate data interpretation and decision-making.
To get the most out of the DAX median calculation, you should always validate your results. And that involves checking with other tools or manual calculations. Validating your results helps you ascertain that the median values align with expectations.
Aside from calculating the DAX median, this guide also reveals how to create an attractive dashboard in Power.
Now you know how to find out median, what data will you be analyzing using the Sankey Chart in Power BI?