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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MikeTBX
New Member

Counting Occurrences of Text in Table and Displaying in Column Chart

Hello,

 

I'm trying to figure out how to display data in a particular way and can't figure out the combo of measures and options to get it done. This would be a similar example of what I have:

 

Colors
Blue
Green, Red
Red, Blue
Yellow
Red
Blue, Yellow, Red

 

What I'd like to do is display a column chart that counts how many cells contain a particular color. So along the x-axis it would have Blue (value of 3), Green (value of 1), Red (value of 4), Yellow (Value of 2).

 

If I just do the simplest thing and create a column chart with Colors on the x-axis and "count of colors" on the y-axis, it creates 6 different columns 1 high of "Blue"; "Green, Red"; "Red, Blue"; etc.

 

I've tried creating another data table that just lists the individual colors, set a relationship back to the original column, and then set the individual colors along the axis. That successfully filters to just the individual colors, "Blue", "Green", "Red", and "Yellow", but it only counts the unqiue occurrences when it is the only color listed. So "Blue" displays as 1 because it counts "Blue", but not "Red, Blue" or "Blue, Yellow, Red".

 

Alternatively, I've created new calculated columns in the data table that does a search for each term and can let me sum that column to get the accurate numbers ... but then I don't know what to put on the X-Axis.

 

At this point I'm so far deep in the rabbit hole I can't see the forrest for the trees. Don't know what to try next. Any suggestions?

 

Thanks!

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, split the column by rows.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, split the column by rows.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks Ashish! This did ultimately get me to what I wanted to do.

 

I was so focused on using a measure or counter or something with filters that I didn't think to create a new table just for this specific purpose. I have other columns and functions on my data where I couldn't create new rows without it messing up other calculations. However, using the same source data I create a new table just to get the color counts.

 

Created a new table from the same source document, removed the columns I wouldn't need, split the "Colors" column with the comma delimiter into new rows, and then I could do counts and match things up just fine. I created a relationship back to the third table that just has the list of colors with a one-to-many relationship that I can put along the X-axis and now I'm golden. It's doing the calculations right and helping me digest the data in a way I want to see it.

 

 

Thanks again!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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