How To Calculate Median In Power Bi

Calculating Median in Power BI

Median is a statistical measure that represents the middle value of a dataset when it is sorted in ascending or descending order. In Power BI, you can calculate the median using several methods, such as DAX formulas or through visualizations.

DAX Formula Method:

To calculate the median using a DAX formula, you can follow these steps:

  1. Create a new measure by going to the “Modeling” tab in the Power BI Desktop.
  2. Click on “New Measure” in the “Calculations” group.
  3. Enter a formula that calculates the median using the MEDIANX function. For example:
  4. 
            Median = MEDIANX('Table', 'Table'[Column])
            

    Replace ‘Table’ with your actual table name and ‘Column’ with the column name from which you want to calculate the median.

  5. Apply the measure to a visualization, such as a table or a card, to display the calculated median.

Visualization Method:

Another way to calculate the median in Power BI is by using visualizations. You can use a table or a matrix visualization to display your data, and Power BI will automatically calculate and display the median for each column.

  1. Create a table or matrix visualization by dragging the desired columns to the visualization pane.
  2. Ensure that the “Values” section of the visualization pane shows “Median” as the aggregation method for the column.
  3. Power BI will calculate the median for each column and display it in the visualization.

Example:

Let’s consider an example where we have a table named “Sales” with two columns – “Product” and “Revenue”. To calculate the median revenue using the DAX formula method, you can use this formula:


    Median Revenue = MEDIANX(Sales, Sales[Revenue])
    

If you prefer the visualization method, you can simply create a table or matrix visualization with the “Revenue” column, and Power BI will calculate and display the median automatically.

Read more interesting post

Leave a comment