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 all,
I am having a bit of trouble with calculating percentage values from categories, in which data can be one of two values. After spending a good amount of time with this I can't really phrase this question right, so I would give you an example.
My data looks similar to this:
... | Category | Status | ...
... | 1 | Passed | ...
... | 1 | Breached | ...
... | 2 | Passed | ...
... | 2 | Passed | ...
and so on.
There are four categories in total (1-2-3-4), and three separate columns for three "statuses".
I've tried with making another table, where status occurancies are summarized by category (i.e., how many have passed in 1st).
I would need to calculate and display how many % of all rows are passed in each category. How would you approach this problem?
Thanks in advance,
Simon
Solved! Go to Solution.
Sorry @SimonNagy
In the all, it should be:
% total= DIVIDE(
[Total status],
CALCULATE([Total status],ALL(MyTable[Status])))
Hi @SimonNagy ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a measure.
% Measure =
var _a=COUNTROWS(FILTER(ALL('Table'),'Table'[Category]=MAX('Table'[Category]) && 'Table'[Status]="Passed"))
var _b=COUNTROWS(FILTER(ALL('Table'),'Table'[Category]=MAX('Table'[Category]) ))
return DIVIDE(_a,_b)
(3)If you want a table, you can create the table.
Table 2 = SUMMARIZE('Table','Table'[Category],"%",[% Measure])
(4) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-tangjie-msft and @mlsx4 !
Thank you for your inputs/answers, I've managed to figure it out! As my data is a bit more complex, I've needed to incorporate more steps, but generally using measures were the anwser. Earlies I've complicated things by using dax studio, and making tables from categorizations 😄
Best regards,
Simon
Hi @SimonNagy ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a measure.
% Measure =
var _a=COUNTROWS(FILTER(ALL('Table'),'Table'[Category]=MAX('Table'[Category]) && 'Table'[Status]="Passed"))
var _b=COUNTROWS(FILTER(ALL('Table'),'Table'[Category]=MAX('Table'[Category]) ))
return DIVIDE(_a,_b)
(3)If you want a table, you can create the table.
Table 2 = SUMMARIZE('Table','Table'[Category],"%",[% Measure])
(4) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @SimonNagy
Something like this should work:
Total status = COUNTROWS(MyTable)
% total= DIVIDE(
[Total status],
CALCULATE([Total status],ALL(MyTable[Category])))
Hi @mlsx4 ,
thank you for your answer!
I've made the measure, you wrote, and it returned back the distribution of the categories in the table (e.g., .07 of rows are in the 1st category). I think you've put me on the right tracks, though I would need to calculate how many rows are passed in each category.
Cheers,
Simon
Sorry @SimonNagy
In the all, it should be:
% total= DIVIDE(
[Total status],
CALCULATE([Total status],ALL(MyTable[Status])))
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 |
---|---|
107 | |
100 | |
85 | |
77 | |
66 |
User | Count |
---|---|
120 | |
112 | |
94 | |
84 | |
75 |