The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi,
I am looking for some help regarding a bar chart that shows the percentage of the count of a type of subcategory (selected in my filter) based on the total number of a category specified in time. Basically the data I have looks like this:
Category | Week | Subcategory |
A | 1 | x |
A | 2 | y |
A | 2 | x |
A | 2 | z |
A | 2 | y |
A | 2 | y |
A | 3 | x |
A | 3 | z |
A | 3 | x |
B | 3 | x |
B | 3 | y |
C | 1 | z |
And I want to apply the following filters:
Filter on Category | A |
Filter on Subcategory | x |
Filter on week | [All] |
After which I want to show the percentage of counted "x" relative to the total count of "A" per week, i.e. a result (in a bar graph that basically shows:
Category | Subcategory | Week | % of Category |
A | x | 1 | 100% |
2 | 20% | ||
3 | 67% |
So far, my attempts have not gotten me far (not very experienced yet) and when using metrics to calculate totals and percentages, the Category "A" changes with the filter "x". In other words I keep getting 100% as an outcome in the end. Could someone help me with this?
Thanks a lot!
Solved! Go to Solution.
Try this MEASURE
% of category = DIVIDE ( COUNT ( TableName[Subcategory] ), CALCULATE ( COUNT ( TableName[Subcategory] ), ALLEXCEPT ( TableName, TableName[Category], TableName[Week ] ) ) )
Hi,
This is good, it is working in matrix table, but not working for bar chart.... here is the scenario:
i have data of around 10k records with consists of name, months, multiple subcategories (poor, good, very good, excellent) in column1
My question is i want to display month wise % of good, poor, very good, excellenet in bar chart.. i wnat to display & on each bar.
Hi,
Share data in a format that can b pasted in an MS Excel file. Ensure that there is also a Year column (along with Month column) in your dataset.
Hi,
Try this measure
=COUNTROWS(Table1)/CALCULATE(COUNTROWS(Table1),ALL(Table1[Subcategory]))
Hope this helps.
Thanks, for my specific question this works as well.
Difference with the solution of @Zubair_Muhammad is that with that solution I can select multiple filters (i.e. a second category related to the above data), while keeping the "base value" the same (i.e. the number of "A"'s). With your solution it is possible to select an additional filter, which than becomes the new "base value".
Try this MEASURE
% of category = DIVIDE ( COUNT ( TableName[Subcategory] ), CALCULATE ( COUNT ( TableName[Subcategory] ), ALLEXCEPT ( TableName, TableName[Category], TableName[Week ] ) ) )
But i get different results wth your sample data
My percentages were atually wrong, I will change it in the original answer, solutions works for me!
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
108 | |
77 | |
73 | |
47 | |
39 |
User | Count |
---|---|
137 | |
108 | |
69 | |
64 | |
56 |