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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DeveshSeth
Helper II
Helper II

Add a % column to matrix visual

Hello friends

 

What I want to establish is probably best explained by an example.

 

Let's say I have the following table:

ToyGood/Bad
AbacusGood 
AbacusBad
AbacusBad
AbacusBad
PuzzleGood
PuzzleBad
PuzzleBad
DollGood
DollGood
DollGood

 

I do a matrix visual in PBI with toys as row labels and good/bas as columns:

Row LabelsBadGoodGrand Total
Abacus314
Doll 33
Puzzle213
Grand Total55

10

 

I want to add another column (see below):

Row LabelsBadGoodGrand TotalPercentage of Good Toys
Abacus31425%
Doll 33100%
Puzzle21333%
Grand Total551050%

 

What's the best way to achieve this?

 

Many thanks in advance.

Devesh

 

1 ACCEPTED SOLUTION

@DeveshSeth you don't' need to put good/bad on columns, just 4 measures that are created.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

16 REPLIES 16
parry2k
Super User
Super User

@DeveshSeth here is the measure

 

% Good = DIVIDE ( CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Good/Bad] = "Good" ), COUNTROWS ( 'Table' ) )

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k Thanks, I think we're close but how do I use the measure in the matrix visual to obtain the table (with % good column) I provided in my question. When I add it to the matrix visual I get the attached table - with extra columns that are not wantedtable.jpg.

The table columns should look like this:

Row LabelsBadGoodGrand TotalPercentage of Good Toys
Abacus31425%
Doll 33100%
Puzzle21333%
Grand Total5510100%

 

 
 

Hi,

This is not a method i'd prefer to use but i had to.  You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish

 

Thanks, but your solution is starting with a pivot of the original table and hence it is possible to visualize via a 'Table' visual. 

How do I start with the table posted in my original question and still achieve the intended solution?

Thanks

Devesh

Sorry I see the pivot step in M query now. 

Hi,

If my reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks again Ashish. For many reasons, I wanted the solution to use the matrix visualization with the columns mentioned. Specially because the table has a lot of other columns/processed data and is used for multiple other reports/dashboards - hence it won't be possible to pivot in M unless am doing that for only this visualization separately. 

The data I used in a simple stylized example to explain the problem.

Hi,

Here's another bad method, yet a method.  You may download my PBI file from here.

Hope this helps.

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

You are welcome.  In which case, i dno't think you will get a perfect solution to this problem.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@DeveshSeth do you have only two categories good and bad, if yes then you can add following measures, and without doing any transformation, you can use table/matrix visual

 

Total = COUNTROWS( Table )

Good = CALCULATE( [Total], Table[Good/Bad] = "Good" )

Bad = CALCULATE( [Total], Table[Good/Bad] = "Bad" )

 

use the above measures in  your visual

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation! Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

But the question still remains - how do I get the percentage column in my matrix visual? 

@DeveshSeth you can use the same % calculation which I provided before, nothing changed on that. You should be able to take it from here.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation! Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Unfortunately, putting % good column in matrix visual gives me this:

 

table.jpg

I have put Toys as row label and Good/bad as columns, value field has 'Count of Good Bad' and '%Good". Could you tell me what are you putting in your matrix visual to give you the result as outlined in my original question?

 

 

@DeveshSeth you don't' need to put good/bad on columns, just 4 measures that are created.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Bingo. Magic! 

Many thanks for the solution and also for bearing with my naivety. 

As you probably said, this wouldn't be a preferred solution. In my case, the table itself has multiple columns and many other processing step and Ideally I wouldn't want to pivot the whole data in M query. The pivoting step is preferred last (as a matrix visual) after data transformation, adding business logic (including in M and DAX) is done.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.