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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
smillward
Frequent Visitor

Searching/Counting mutiple values from one cell

So currently i have a column storing multiple values in one cell (it captures answers from a multiple select survey),

 

So the column contains values such as

1.   Alpha 1

2.   Alpha 5

3.   Alpha 1, Alpha 5

4.   Alpha 1, Alpha 10

5.   Alpha 10

 

I want to count the number of rows with each value, so the desired output would be:

Alpha 1: 3

Alpha 5: 2

Alpha 10: 2

 

however I can't get it to count Alpha 1 properly.

 

I've been trying to use the SEARCH function combined with calculate to get at these, however my attempts so far have Failed to produce the desired result

My current formula is

Measure 1 : = CALCULATE ( COUNTROWS (Table), SEARCH ( "*Alpha 1,*", Table[Column],,0 ) > 0 )+ CALCULATE ( COUNTROWS ( Table), SEARCH ( "*Alpha 1", Table[Column],,0 ) > 0)

 

In my head, the first calculate function should count the rows where it finds the string "Alpha 1," which would be 3 and 4, then add it to the rows where it finds "Alpha 1" and immediately terminates, which would be row 1.

The second calculate function seems to be returning all rows where it finds "*Alpha 1*", and not "*Alpha 1%END OF STRING%, so it returns 1, 3, 4 and 5. so my end results is:

Alpha 1: 6

Alpha 5: 2

Alpha 10: 2

 

If anyone can help me understand what I'm missing, I would be most grateful

         

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @smillward,

 

Based on my test, the formula below should work in your scenario. Smiley Happy

Measure =
CALCULATE ( COUNTROWS ( Table1 ), SEARCH ( "Alpha 1", Table1[Column],, 0 ) > 0 )
    - CALCULATE (
        COUNTROWS ( Table1 ),
        SEARCH ( "Alpha 1?", Table1[Column],, 0 ) > 0
            && SEARCH ( "Alpha 1,", Table1[Column],, 0 ) = 0
    )

 

Regards

View solution in original post

4 REPLIES 4
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @smillward,

 

Based on my test, the formula below should work in your scenario. Smiley Happy

Measure =
CALCULATE ( COUNTROWS ( Table1 ), SEARCH ( "Alpha 1", Table1[Column],, 0 ) > 0 )
    - CALCULATE (
        COUNTROWS ( Table1 ),
        SEARCH ( "Alpha 1?", Table1[Column],, 0 ) > 0
            && SEARCH ( "Alpha 1,", Table1[Column],, 0 ) = 0
    )

 

Regards

Thanks that does seem to be working perfectly.

 

So given that * isn't needed as a wildcard, can you explain what the ? represents in the string. is it an END charachter?

Hi @smillward,

 

A question mark(?) matches any single character. For example, "Alpha 1?" can represent both "Alpha 10" and "Alpha 1," in your sample data. Smiley Happy

 

Regards

jthomson
Solution Sage
Solution Sage

That the string "Alpha 10" contains "Alpha 1" as part of it is probably going to throw it off in some way?

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors