Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Eric5605
Frequent Visitor

How to calculate the variance to average in one column of a table

Hi, this table shows the average of survey scores (1 to 7) for all respondents grouped by agency.  I am trying to apply conditional formatting that would highlight green for any question response that is greater than 0.5 above or below the overall average.  For example question 1 has an overall average of 5.20.  Any agency averaging 4.7 or less would highlight red and any agency 5.7 or greater would highlight green.  What would be the correct DAX formula to calculate the difference of the agency's average for a particular question vs the average for all agencies for a particular question?  Thanks in advance!

Eric5605_0-1696534386164.png

 

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @Eric5605 ,

I assume that [Q1-Process], [Q2-Insider Threat], [Q3-Data Systems], and [Q4-Reporting] are all measures.
For [Q1-Process], you can create a new measure like this.

Measure = 
VAR __OverallAverage =
    AVERAGEX ( ALL ( 'Table'[Agency] ), [Q1-Process] )
VAR __Average = [Q1-Process]
VAR __Result =
    SWITCH (
        TRUE (),
        __Average - __OverallAverage > 0.5, "Green",
        __Average - __OverallAverage < -0.5, "Red"
    )
RETURN
    __Result

Apply it to the [Q1-Process]'s conditional formatting and the output:

vcgaomsft_0-1696929177440.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

4 REPLIES 4
v-cgao-msft
Community Support
Community Support

Hi @Eric5605 ,

I assume that [Q1-Process], [Q2-Insider Threat], [Q3-Data Systems], and [Q4-Reporting] are all measures.
For [Q1-Process], you can create a new measure like this.

Measure = 
VAR __OverallAverage =
    AVERAGEX ( ALL ( 'Table'[Agency] ), [Q1-Process] )
VAR __Average = [Q1-Process]
VAR __Result =
    SWITCH (
        TRUE (),
        __Average - __OverallAverage > 0.5, "Green",
        __Average - __OverallAverage < -0.5, "Red"
    )
RETURN
    __Result

Apply it to the [Q1-Process]'s conditional formatting and the output:

vcgaomsft_0-1696929177440.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Worked great!  Thank you!!!!!

Ritaf1983
Super User
Super User

AgencyRespondentsQ1-ProcessQ2-Insider ThreatQ3-Data SystemsQ4-Reporting
Department of Agriculture9154.905.225.156.13
Department of Commerce3315.185.405.306.40
Department of Defense41805.325.455.336.41
Department of Education1045.425.595.496.25
Department of Energy2905.335.455.286.39
Department of Health and Human Services5985.115.405.406.27
Department of Homeland Security13995.115.375.286.31
Department of Housing and Urban Development755.165.415.486.20
Department of Justice5185.375.555.466.34
Department of Labor1415.245.385.346.14
Department of State6904.694.874.676.36
Department of the Interior5375.145.305.296.18
Department of the Treasury6885.315.485.466.27
Department of Transportation7265.275.535.476.31
Department of Veterans Affairs14534.995.265.336.10
Environmental Protection Agency3584.965.385.146.27
General Services Administration2945.595.795.766.33
National Aeronautics and Space Administration2225.745.915.706.46
National Science Foundation585.165.405.346.43
Nuclear Regulatory Commission555.585.675.516.49
Office of Personnel Management515.395.555.456.61
Small Business Administration595.855.905.816.53
Social Security Administration7445.375.505.546.28
Total respondants and average for questions144865.275.475.396.32

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.