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
Anonymous
Not applicable

Counting responses in rows - multiple text strings needs to be ignored

Hi Forum

I need to count rows with a measure where there are some "regular", and some "mixed" responses to a survey all stuck in one column. I need to count the columns where "other" responses where provided.

For simplicity, lets call the regular responses A, B and C.

All regular responses A's, B's and C's are always the same, so A might be = "yes", B = "no", C = "don't know", as an example.
And lets call all other responses X. X can be anything. Like - X = "this is a stupid survey" or X = "why are we doing this"

So the data might be as follows in my Survey_Column:
row 1 : A; B; C
row 2 : A; B
row 3 : X
row 4 : X; A; B

I've tried:

CALCULATE(
COUNTROWS('Table'),
SEARCH("A",'Table'[Survey_Column],1,-1)=-1,
SEARCH("B",'Table'[Survey_Column],1,-1)=-1,
SEARCH("C",'Table'[Survey_Column],1,-1)=-1
)

This returns a count of 1, since all the rows with A, B and C has been left out. But I need the count to be 2, since there are two rows where other responses were provided?

2 ACCEPTED SOLUTIONS
AlB
Community Champion
Community Champion

Hi @Anonymous 

This is easiest done in Power Query. You can create an additional column that will tell you if "other" answers were provided. Then you can operate on that column very easily in DAX. Place the following M code in a blank query to see the steps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcrRWcLJWcFaK1YGwwYwICGmtABGJBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),

    validResponses_ = {"A", "B", "C"}, 
    #"Added Custom" = Table.AddColumn(Source, "Other responses provided?", each if List.Count(List.Difference(Text.Split([Column1],"; "), validResponses_)) >0 then true else false, type logical)
in
    #"Added Custom"

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

   

View solution in original post

wdx223_Daniel
Super User
Super User

@Anonymous PowerQuery is the better selection. if you insist resolve it in DAX,please refer the below code

wdx223_Daniel_0-1607588396017.png

 

View solution in original post

2 REPLIES 2
wdx223_Daniel
Super User
Super User

@Anonymous PowerQuery is the better selection. if you insist resolve it in DAX,please refer the below code

wdx223_Daniel_0-1607588396017.png

 

AlB
Community Champion
Community Champion

Hi @Anonymous 

This is easiest done in Power Query. You can create an additional column that will tell you if "other" answers were provided. Then you can operate on that column very easily in DAX. Place the following M code in a blank query to see the steps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcrRWcLJWcFaK1YGwwYwICGmtABGJBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),

    validResponses_ = {"A", "B", "C"}, 
    #"Added Custom" = Table.AddColumn(Source, "Other responses provided?", each if List.Count(List.Difference(Text.Split([Column1],"; "), validResponses_)) >0 then true else false, type logical)
in
    #"Added Custom"

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

   

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.