Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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 whe...
  • AlB's avatar
    5 years ago

    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 

     

       

  • wdx223_Daniel's avatar
    5 years ago

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