Plot Normal Distribution Using Median

 

Step-by-Step Guide to Plot Normal Distribution Using Median

Step 1: Calculate the Median and Interquartile Range

  1. Create Measures for Median and Interquartile Range (IQR):

    • Go to the Modeling tab in Power BI Desktop.

    • Click on "New Measure" and create the following measures.

dax
MedianTaskAge = MEDIAN('Tasks'[Task Age])
dax
Percentile25 = PERCENTILEX.INC('Tasks', 'Tasks'[Task Age], 0.25)
dax
Percentile75 = PERCENTILEX.INC('Tasks', 'Tasks'[Task Age], 0.75)
dax
IQRTaskAge = [Percentile75] - [Percentile25]

Step 2: Create a Normal Distribution Function Using Median and IQR

  1. Create a Measure for the Normal Distribution Function:

    • Click on "New Measure" again and create a measure for the normal distribution function.

dax
NormalDistUsingMedian = 
VAR Median = [MedianTaskAge]
VAR IQR = [IQRTaskAge]
VAR Value = SELECTEDVALUE('Tasks'[Task Age])
RETURN
1 / (IQR * SQRT(2 * PI())) * EXP(-0.5 * ((Value - Median) / IQR) ^ 2)

Step 3: Create a Supporting Table for the Distribution

  1. Create a New Table:

    • Go to the Modeling tab and click on "New Table".

    • Create a table with a range of values to plot the normal distribution.

dax
NormalDistTable = GENERATESERIES(MIN('Tasks'[Task Age]), MAX('Tasks'[Task Age]), 1)

Step 4: Create the Normal Distribution Values Using Median

  1. Create a New Column in the Supporting Table:

    • Add a calculated column in the NormalDistTable to evaluate the normal distribution function.

dax
NormalDistValueUsingMedian = 
VAR Median = [MedianTaskAge]
VAR IQR = [IQRTaskAge]
VAR Value = [Value]
RETURN
1 / (IQR * SQRT(2 * PI())) * EXP(-0.5 * ((Value - Median) / IQR) ^ 2)

Step 5: Plot the Normal Distribution in a Line Chart

  1. Create a Line Chart:

    • Go to the Report view and insert a Line chart visual.

    • Add the NormalDistTable's Value column to the X-axis.

    • Add the NormalDistValueUsingMedian column to the Y-axis.

Explanation:

  • MedianTaskAge: Calculates the median of Task Age.

  • Percentile25 and Percentile75: Calculate the 25th and 75th percentiles of Task Age, respectively.

  • IQRTaskAge: Calculates the interquartile range (IQR) of Task Age.

  • NormalDistUsingMedian: Calculates the normal distribution values based on the median and IQR.

  • NormalDistTable: Creates a series of values to plot the normal distribution curve.

  • NormalDistValueUsingMedian: Calculates the normal distribution function for each value in the supporting table using the median and IQR.

By following these steps, you can create a normal distribution plot for "Task Age" in Power BI using the median instead of the mean, providing a visualization based on the median-centered distribution.

No comments

Theme images by tjasam. Powered by Blogger.