Forum Discussion

shere100's avatar
shere100
Helper II
7 years ago
Solved

Simple Calculation required

Hi, I need to do some simple percentage calaculation on two columns. 

 

Not Started56
Pass20
Fail2
Total Work Items78

 

I need to display the percentage of success rate. I.e the calculation would be 20 (pass) / 56 (not started) * 100.

 

Can you please talk me through the process. Thanks 

  • Hi shere100 

    You may create a measure with COUNTX Function.For example:

    Measure 2 =
    COUNTX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Test Result] = "Pass" ),
        'Table'[Test Result]
    )
        / COUNTX (
            FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Test Result] = "Not Started" ),
            'Table'[Test Result]
        )
    

    Regards,

16 Replies

  • v-cherch-msft's avatar
    v-cherch-msft
    Microsoft Employee

    Hi shere100 

    You may create a measure and then set the measure's format %.

    Measure =
    SUMX ( FILTER ( Table2, Table2[Status] = "Pass" ), Table2[Value] )
        / SUMX ( FILTER ( Table2, Table2[Status] = "Not Started" ), Table2[Value] )
    

    Regards,

    • shere100's avatar
      shere100
      Helper II

      Thanks for the above, much appreciated.

       

      The values in the orignal post are based not from the raw data but from the filters selected on a visual and the results displayed

       

      How do I then use the measure on the filtered values? If I use the query you have kindly provided me this will not calculate the totals for each status and then measure the totals? 

       

      Or how would I calculate the results from the raw data then use the measure calculation you have provided?

      • v-cherch-msft's avatar
        v-cherch-msft
        Microsoft Employee

        Hi shere100 

        You may try to use ALLSELECTED Function.For example:

        Measure =
        SUMX (
            FILTER ( ALLSELECTED ( Table2 ), Table2[Status] = "Pass" ),
            Table2[Value]
        )
            / SUMX (
                FILTER ( ALLSELECTED ( Table2 ), Table2[Status] = "Not Started" ),
                Table2[Value]
            )
        

        Regards,