Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello all!
Looking for some guidance on how to resolve the following scenario.
I have two tables:
FACTS
RecordID (number)
BusinessUnit (text)
ReportNum (text)
CODES TABLE
Code (text)
CodeType (text)
ReportNum (text)
I have a relationship between these two tables using ReportNum (one->many). I'm trying to create a matrix table that will show the top 5 codes for each BusinessUnit using the count of the ReportNum. I've read lots of posts, etc. about RANKX but a lot of the examples use calculation of "total sales" or other numerical values. I've tried replacing some of the code with COUNT instead, but I am still not getting the results I'm looking for. It seems to be calculating the same total count for each business unit and code. Either that, or it's calculating the ranking based on just the code, and not the BU+Code. Here is what I am looking for, as far as output in a visualization (matrix table form):
Business Unit/Code
BU1
Insufficient Information, 120
Foreign Matter, 99
Swelling, 15
Seroma, 6
Pain, 2
BU2
Discomfort, 344
Blister, 42
Headache, 41
Fatigue, 12
Pain, 9
Any help would be sooo appreciated!
Dee
Solved! Go to Solution.
Sorry for so many replies! I figured out that this is working as long as I have all of the data in one table. I wasn't sure how to rank the count of codes, where the codes were in the "many" table of the one-many relationship between my facts table and my code table. What I ended up doing was adding a new calculated column into my CODES table to pull the name of the BusinessUnit in using the RELATED calculation. Now if I perform my ranking all in one table (the CODES table) it's working fine. I'm still curious how this would be able to work, however, using both tables!
Sorry for so many replies! I figured out that this is working as long as I have all of the data in one table. I wasn't sure how to rank the count of codes, where the codes were in the "many" table of the one-many relationship between my facts table and my code table. What I ended up doing was adding a new calculated column into my CODES table to pull the name of the BusinessUnit in using the RELATED calculation. Now if I perform my ranking all in one table (the CODES table) it's working fine. I'm still curious how this would be able to work, however, using both tables!
Hi, @goatmonslc
It looks like you have found a solution. Could you please mark this helpful post as “Answered”?
This will help others in the community to easily find a solution if they are experiencing the same problem as you.
Thank you for your cooperation!
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Did you try to create a simple measure with the count, and then use it to filter the visualize with a rank?
Yes, I have a measure called "CodeCount":
OK the count is working, my Rank shows up with ranking 1 for each BusinessUnit 'Code'.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 38 | |
| 37 | |
| 28 | |
| 28 |
| User | Count |
|---|---|
| 124 | |
| 89 | |
| 73 | |
| 66 | |
| 65 |