Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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
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
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
73 | |
71 | |
55 | |
37 | |
32 |
User | Count |
---|---|
71 | |
65 | |
60 | |
50 | |
45 |