Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ElliotGPro
Frequent Visitor

Need help creating matrix of counts for column values

Okay so I did some digging and got no hits with the search so here's hoping that someone on here might be able to give me a hand. So I have the below table currently, it is a matrix of a bunch of people and a bunch of categories, and how many numbers each person has in each category. This is very simplified data, but I can't post any of the raw data for privacy reasons.

 

ElliotGPro_0-1717636331055.png

Basically what I am trying to do is rather than see how many of each category each person has, I want to know how many people have that many numbers asssociated with the category. I just did a quick manual one to show the basic output I'm trying to get with this simple test data. I can't do this manually for the actual data, since there is about 20 categories and over 80000 people, so it really isn't feasible.

ElliotGPro_1-1717636778603.png

I tried a couple different ways like putting the numbers as the columns and creating a measure to put the to force it to be count, but neither of those worked since (as I found out from experimenting with this) you can't have aggregates as column values, or at least you can't how I tried to. I am still pretty new to BI in general and am the only analytics member in my team, so any help from the wider fabric community would be much appreciated. I also can't figure out how to upload my excel file directly, so I'm just going to put the table with the data in it directly into this post at the bottom. Apologies if that isn't the best way to do that.

 

Thanks in advance,

Elliot

 

Data:

PersonCategoryNumber
ACat 11
BCat 12
CCat 13
DCat 14
ECat 15
FCat 16
GCat 17
HCat 18
ACat 19
BCat 110
CCat 111
DCat 112
ECat 113
FCat 114
GCat 315
HCat 316
ACat 317
BCat 318
CCat 319
DCat 320
ECat 321
FCat 322
GCat 323
HCat 324
ACat 325
BCat 326
CCat 327
DCat 428
ECat 429
FCat 430
GCat 431
HCat 432
ACat 433
BCat 434
CCat 435
DCat 436
ECat 437
FCat 438
GCat 439
HCat 440
ACat 241
BCat 242
CCat 243
DCat 244
ECat 245
FCat 246
GCat 247
HCat 248
ACat 249
1 ACCEPTED SOLUTION
ElliotGPro
Frequent Visitor

I have since solved this problem, and I'll just write a quick solution on here in case anyone comes across it with the same problem.

 

Basically my initial data needed to be placed into a group by function. Turns out, Power BI has a similar function called SUMMARIZE. Nifty little calculation but by creating a new table that uses SUMMARIZE to summarize by person and category, and counting how many rows of those groups there are, it gives a table that can be used to generate the matrix that I have pictured above in my intial question. The table function should look something like the below code snippet:

 

GroupBy4 = SUMMARIZE(TableName, TableName[Category], TableName[Person], "Count of People", COUNT(TableName[Person]))

View solution in original post

5 REPLIES 5
ElliotGPro
Frequent Visitor

I have since solved this problem, and I'll just write a quick solution on here in case anyone comes across it with the same problem.

 

Basically my initial data needed to be placed into a group by function. Turns out, Power BI has a similar function called SUMMARIZE. Nifty little calculation but by creating a new table that uses SUMMARIZE to summarize by person and category, and counting how many rows of those groups there are, it gives a table that can be used to generate the matrix that I have pictured above in my intial question. The table function should look something like the below code snippet:

 

GroupBy4 = SUMMARIZE(TableName, TableName[Category], TableName[Person], "Count of People", COUNT(TableName[Person]))
Ritaf1983
Super User
Super User

Hi @ElliotGPro 
You just need to put the numbers as "columns" 
and then you can use a simple discount measure :

Ritaf1983_0-1717638782713.png

Ther measure :

count_ = DISTINCTCOUNT('Table'[Person])
 I slightly modified your data to enable counting since you have only one value for each number
PBIX is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

You have missed what I am looking for. Those numbers are all unique, I am looking to count how many of them exist for the person. The numbers themselves don't matter, only how many of them there are. Also you don't need a measure to create a distinct count, you can just put the people into the values column and change it from count to distinct count.

When someone "misses" something in our question, it could be that we haven't expressed ourselves properly. Therefore, blaming someone who is trying to help in their free time without any compensation is less likely to lead you to a solution.

Instead of getting angry, I would think about clarifying the question in a more understandable way. At least to me, it's still not clear.

Regarding "no measures are needed," the efficient way to work with Power BI is to build measures. This allows for flexibility as you continue to work, sometimes prevents errors, and improves performance.

Good luck,

Rita

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Sorry, yes of course, we are all volunteers. I didn't mean to come of quite as snarky as I did in that last reply but yeah re-reading, probably not the best way to respond.

 

As for how to make it clearer, I did put an image of what I'm trying to get to in my main post and did mention that those numbers are meant to be unique, they aren't supposed to be duplicates like you made them in the data you put into your table, though ultimately they could just as much be all the same number, it is just a value there to represent that this person has a record matching this event.

 

The first image is of how many records a person has in each event. I am trying to show how many people have that same number of claims in that event in the second matrix. So for the Cat 1 category, there were 2 people that had 1 record with that category, and 6 people that had 2 records with that category. That's what I'm trying to represent, hope that makes it slightly clearer.

 

Oh and thanks for the tip with the measures, I didn't realise it was more efficient to make a measure for the distinct count rather than use the distinct count object when it is in the values cell.

Elliot

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.