Count Rows if the text contains a specific string

I am trying to combine CountX with a filter for another field in the row that contains a specific string.

This is what I tried (below). I don’t get an error for the specific measure, but when I include it in a visualization, I get ‘can’t display this visual’.

Orders COUNT CORP = CALCULATE (
    COUNTX ( Orders,[Order ID] ),
    FILTER (
        Orders,
        Orders[Product Name] = CONTAINSSTRING ( Orders[Product Name], "Corp" )
    )
)

I’d appreciate any help with understanding what I am missing. I am not that familiar with using CONTAINSSTRING .

@ScottTPA,

Try changing your measure to this:

Orders COUNT CORP = 
CALCULATE (
    COUNTX ( Orders,[Order ID] ),
    FILTER (
        Orders,
        CONTAINSSTRING ( Orders[Product Name], "Corp" ) = TRUE
    )
) 
  • Brian
2 Likes

Brilliant! It worked. Thank you @BrianJ This forum is invaluable thanks to people like you.

@ScottTPA,

:+1:. Thanks for the kind words. Glad that worked well for you.

  • Brian