Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Power bi desktop

Hi All, 

I have a table in which Column A has some values and I am trying to calculate percentage as shown in below table:

 

Column A
abc
abc
xyz
xyz
abc
abc

 

Percentage
abcxyz
66.66%33.33%

 

 

Is there any query that can give me the percentage as shown above?

 

 

 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous 

    (1)Create a column to count the number of category .

    column A num = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Column A]))

    (2)Create a column to count the number of the table

    whole num = COUNTROWS('Table')

    (3)Create a column to count the percentage

    percentage = 'Table'[column A num]/'Table'[whole num]

    Then add a Matrix visual and put Column A into Columns ,put percentage into Values .

    The final result is as shown :

    I have attached my pbix file ,you can refer to it .

     

    Best Regards

    Community Support Team _ Ailsa Tao

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous , Create a measure like

    percent = divide( countrows(Table), calculate( countrows(Table), allselected(Table)))

    // mark as % in measure tool

     

     

    In matrix , Enable  : Show on row

    Use column on Column of matrix. Nothing on row

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

    (1)Create a column to count the number of category .

    column A num = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Column A]))

    (2)Create a column to count the number of the table

    whole num = COUNTROWS('Table')

    (3)Create a column to count the percentage

    percentage = 'Table'[column A num]/'Table'[whole num]

    Then add a Matrix visual and put Column A into Columns ,put percentage into Values .

    The final result is as shown :

    I have attached my pbix file ,you can refer to it .

     

    Best Regards

    Community Support Team _ Ailsa Tao

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.