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

Join 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.

Reply
CF123
Frequent Visitor

Count occurrence of string value in a column

Hi, I am creating a risk dashboard, and I want to display some stats about the risks. I have a table of risks and their attributes, such as their risk rating. I want to create a seperate table that counts how many risks have each rating. If there are no risks this with a particular rating, I want the column to return 0.

 

Here's an example of the expected behaviour

 Table 1

Risk IDRisk Rating
R-1Moderate
R-2Severe
R-3Severe
R-4Critical
R-5Moderate
R-6Moderate

 

Table 2

 

Risk RatingCount
Sustainable0
Moderate3
Severe2
Critical1
1 ACCEPTED SOLUTION

Okay,
This can be achieved by relating the tables and using the relatedtable function.
https://learn.microsoft.com/en-us/dax/relatedtable-function-dax
I can show the solution if you share the PBIX file with an example.

If I answered your question, please mark my post as solution, Appreciate your Kudos

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

View solution in original post

5 REPLIES 5
Ritaf1983
Super User
Super User

HI @CF123 ,
Due to my misunderstanding of what you would like to do, I am offering two alternatives
If you are seeking a summarized table as a "data table," you can use the Group by clause in PQ to group by a count.
For the purpose of visualization, it is a count using DAX's COUNT function.
The table will know how to filter it and show the correct count depending on each status once you present it in the table.
This answer offers a similar solution:
https://community.powerbi.com/t5/Desktop/Counting-Buckets/m-p/3136402#M1060789
Please attach a PBIX file with an example if it's something else so we can help you more easily.
If I answered your question, please mark my post as solution, Appreciate your Kudos

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

I want to have a calculated column in table 2 that counts the occurenance of each risk rating in table 1. If a particular rating can't be found in table 1, I need the calculated column to return 0

Okay,
This can be achieved by relating the tables and using the relatedtable function.
https://learn.microsoft.com/en-us/dax/relatedtable-function-dax
I can show the solution if you share the PBIX file with an example.

If I answered your question, please mark my post as solution, Appreciate your Kudos

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

Thanks, I was able to figure it out 🙂

Great job 😍!
Please mark my answer as a solution if it is the result of my idea and guidance. This will help others who encounter the same issue.

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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