Search code examples
powerbimeasure

How to have a measure always show the ratio as percentage in scorecard/textbox POWER BI


There are many method of having a measure to show percentage in a column of table , but cannot find a method to always show the ratio of a SPECIFIC group in percentage between two category.

data sample:

YEAR    MONTH   TYPE    AMOUNT
2020    Jan A   100
2020    Feb A   250
2020    Mar A   230
2020    Jan B   158
2020    Feb B   23
2020    Mar B   46
2019    Jan A   499
2019    Feb A   65
2019    Mar A   289
2019    Jan B   465
2019    Feb B   49
2019    Mar B   446
2018    Jan A   13
2018    Feb A   97
2018    Mar A   26
2018    Jan B   216
2018    Feb B   264
2018    Mar B   29
2018    Jan A   314
2018    Feb A   659
2018    Mar A   226
2018    Jan B   469
2018    Feb B   564
2018    Mar B   164 

My Goal is always show the percentage of A compare with the total amount

YEAR and MONTH are used to synchronize with slicer. e.g. I select YEAR = 2020 , MONTH = Jan 100/258 = 38%

  • Manually inputted in textbox enter image description here

Solution

  • First, Create these following 3 measures in your table-

    1.

    amount_A = 
    CALCULATE(
        SUM(pie_chart_data[AMOUNT]),
        FILTER(
            ALLSELECTED(pie_chart_data),
            pie_chart_data[TYPE] = "A"
        )
    )
    

    2.

    amount_overall = 
    CALCULATE(
        SUM(pie_chart_data[AMOUNT]),
        ALLSELECTED(pie_chart_data)
    )
    

    3.

    amount_A_percentage = [amount_A]/[amount_overall]
    

    Now, add both measure amount_A and amount_overall to your donut chart's values column. And place the amount_A_percentage measure to a Card and place the card in center of the Donut chart. The presentation will be as below finally-

    enter image description here