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.
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:
Area | Category |
Europe | Electric |
Europe | Non-Electric |
America | Electric |
Asia | Non-Electric |
Europe | Non-Electric |
Europe | Electric |
Europe | Non-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:
Area | Electric | Non-Electric |
Europe | 2 | 3 |
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.
Solved! Go to Solution.
Hi,
You may download my PBI file from here.
Hope this helps.
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.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |