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
I am looking to write a DAX calculation that allows me to count by the number of groupings based on the max of one of the attributes of the group. Example data below where there's a group with items inside of it and each item has its own value. I want to count the unique groups that fall into each attribute, based on what the max attribute is of the group. All three below are columns.
Group | Item | AttributeValue |
Group1 | A | 3 |
Group1 | B | 3 |
Group1 | C | 2 |
Group2 | X | 1 |
Group2 | Y | 2 |
Group2 | Z | 3 |
Group3 | Q | 1 |
Group3 | A | 1 |
Then the result I want to produce is a distinct count of groups for each attribute. For example, in the above there are two groups which would fall into Attribute "3" and one group would fall into Attribute "1". Group 1s max is 3, Group 2s max is 3, and Group 3s max is 1. So the visual I need to create would be:
Attribute | GroupCount |
1 | 1 |
2 | 0 |
3 | 2 |
Effectively, I need to be able to bucket each of the groups by the MAX(Attribute) and then count them plus do % of total visualizations so I can see the distribution of the groups by their max item. This also needs to be dynamic as all the columns can be filtered and the count would need to be re-calculated.
Thanks.
Solved! Go to Solution.
Hi, @BUserTG
Please check the below picture and the sample pbix file's link down below.
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: linkedin.com/in/jihwankim1975/
Twitter: twitter.com/Jihwan_JHKIM
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi, @BUserTG
Please check the below picture and the sample pbix file's link down below.
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: linkedin.com/in/jihwankim1975/
Twitter: twitter.com/Jihwan_JHKIM
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Thanks @Jihwan_Kim . This does work except in the case of filtering. For example, if I applied a filter on the Item column, I would want the results to dynamically change. So if I filtered [Item] = 2 then the resultant table should be:
AttributeValue GroupCount
1 0
2 1
3 0
I've tried using an ALLEXCEPT() in the GROUPBY() but that did not work. Any idea on how to make the calculation resilient to filtering on the source table?
Thanks.
ALLSELECTED() should do the trick, seems to be working. Thanks.
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 | |
78 | |
66 | |
52 | |
50 |
User | Count |
---|---|
121 | |
118 | |
77 | |
64 | |
63 |