Forum Discussion

NJ13's avatar
NJ13
Helper I
4 years ago
Solved

Count if

Hello All, 

I need some help please, I want to calculate using count if for a text column, i have a column with words such as boy ; girl ; child ; family ; And ; model and different other combinations for 34 lines.

I am trying to calculate count if that contains a boy (one of each in the sentence above) and it is not returning any numbers.

 

thank you for your help!

  • Hi @ ,

     

    You can create a measure like this:-

    Measure =
    CALCULATE (
        COUNT ( 'Table'[Column1] ),
        CONTAINSSTRING ( 'Table'[Column1], "boy" )
    )

     

    Thanks,

    Samarth

4 Replies

  • Samarth_18's avatar
    Samarth_18
    Community Champion

    Hi @ ,

     

    You can create a measure like this:-

    Measure =
    CALCULATE (
        COUNT ( 'Table'[Column1] ),
        CONTAINSSTRING ( 'Table'[Column1], "boy" )
    )

     

    Thanks,

    Samarth

  • thank you so much, how about if i want multiple strings?

    • Samarth_18's avatar
      Samarth_18
      Community Champion

      You can try like:-

      Measure =
      CALCULATE (
          COUNT ( 'Table'[Column1] ),
          CONTAINSSTRING ( 'Table'[Column1], "boy" ) ||
          CONTAINSSTRING ( 'Table'[Column1], "girl" ) ||
          CONTAINSSTRING ( 'Table'[Column1], "child" 
      )