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
Alenic235
Employee
Employee

Percentage of total by one category in a Matrix as a new column

Hello community,

 

After some research and tries on my own I haven't been able to fully solve this issue. The problem statement with dummy data is as follows:

 

I have a variable called "Area" which defines the territory where the car was sold. Another variable is telling me if the car was electric or not. So my dataset would look like this:

 

AreaCategory
EuropeElectric
EuropeNon-Electric
AmericaElectric
AsiaNon-Electric
EuropeNon-Electric
EuropeElectric
EuropeNon-Electric

 

I am trying to create a matrix which represents the areas as rows, on column will be the categorical variable and then the count of each category as values; for example, for Europe it will look like this:

AreaElectricNon-Electric
Europe23

 

I want to calculate a new measure that simply shows me the ratio between electric cars and total of cars by Area; in this case, for europe, the new column will show 40%, which is 2/ (2+3); each measure I attempted created extra more columns, not just one that would calculate this ratio. 

 

Thank you.

1 ACCEPTED SOLUTION

Hi,

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/

View solution in original post

4 REPLIES 4
speedramps
Super User
Super User

Cars sold =
COUNTROWS[tablename]

Electric cars sold =
CALCULATE(
[Cars sold],
Category = "Electric"
)

Electric % =

DIVIDE(
[Electric cars sold],
[Cars sold]
)

Then format Electric % as a percentatge to 2 decimals


Hey, thank you for your input. This unfortunately has the same result: it creates a new column for each of the category; I need just one column that has the ratio.

Hi,

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/

If you don't want the category, can't you just remove it from the columns field of your matrix?

 

@speedramps has the answer. Just put those three measures (or whatever measures you want) on your table without category on the columns.

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.