Forum Discussion

Premlatapandey9's avatar
Premlatapandey9
Icon for Microsoft Employee rankMicrosoft Employee
4 years ago
Solved

How to calculate % based on row count from 2 tables

Hello Users,   I have a large matrix set up and would like to set up a measure that calculates the total row percentage. ie:   I am taking 2 columns from 2 tables in calculation i.e-     Ta...
  • v-cazheng-msft's avatar
    4 years ago

    Hi @

     

    You may try this solution.

    1 Create a Calculated Table

    Table = SELECTCOLUMNS( {"Total Count Null + Not Null","Null%","Not Null %"},"details",[Value])

     

    2 Create a Measure

    Count&Percent =
    VAR numTable1 =
        COUNTROWS ( 'Table 1' )
    VAR numTable2 =
        COUNTROWS ( 'Table 2' )
    RETURN
        SWITCH (
            MAX ( 'Table'[details] ),
            "Total Count Null + Not Null", numTable1 + numTable2,
            "Null%",
                numTable1 / ( numTable1 + numTable2 ),
            "Not Null %",
                numTable2 / ( numTable1 + numTable2 )
        )

     

    Then, build a Table visual like this.

     

    Also, attached the pbix file as reference.

     

    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 let me know. Thanks a lot!

     

    Best Regards,    

    Community Support Team _ Caiyun