Forum Discussion

tmartyn's avatar
tmartyn
Regular Visitor
2 years ago
Solved

Quartiles and Variance

Hello,   I have a Power Bi file that calculates quartiles using 'PERCENTILEX.INC' which is working fine. My issue is that I would like to calculate the variance of each quartile and I'm not sure ho...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi tmartyn ,

    To calculate the variance for each quartile, you can follow these steps:
    1. Calculate the Mean for Each Quartile:
    You will need to calculate the average (mean) score for each quartile. This can be done by creating a measure that calculates the average for each quartile range.

     

    2. Calculate the Deviation for Each Data Point:
    For each data point (score), calculate the deviation from the quartile mean. This is done by subtracting the quartile mean from each score.

     

    3. Square the Deviation:
    Square the result of each deviation to get the squared deviation.

     

    4. Sum of Squared Deviations:
    Calculate the sum of all squared deviations within the quartile.

     

    5. Calculate the Variance:
    Finally, divide the sum of squared deviations by the count of data points in the quartile minus one (n-1) to get the variance.

     

    Quartile Mean = 
    AVERAGEX(
        FILTER(
            'YourTable',
            'YourTable'[YourScoreColumn] >= [Percentile P1] &&
            'YourTable'[YourScoreColumn] < [Percentile P2]
        ),
        'YourTable'[YourScoreColumn]
    )
    
    Squared Deviation = 
    SUMX(
        FILTER(
            'YourTable',
            'YourTable'[YourScoreColumn] >= [Percentile P1] &&
            'YourTable'[YourScoreColumn] < [Percentile P2]
        ),
        POWER('YourTable'[YourScoreColumn] - [Quartile Mean], 2)
    )
    Variance = 
    [Squared Deviation] / 
    (COUNTROWS(
        FILTER(
            'YourTable',
            'YourTable'[YourScoreColumn] >= [Percentile P1] &&
            'YourTable'[YourScoreColumn] < [Percentile P2]
        )
    ) - 1)

    Please replace 'YourTable' and 'YourScoreColumn' with the actual names of your table and column. Also, adjust the [Percentile P1] and [Percentile P2] to match the quartile ranges you are using.

     

    Best regards,
    Community Support Team_Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.