Forum Discussion

QWERTYZ's avatar
QWERTYZ
New Member
3 years ago
Solved

How to filter by exact string

Hello,

 

I want to count the number of rows in a column that contain the string "rds" . Am using the Filters on this page and selected "Contains: RDS" and a card that shows the count result

But it also retrieves the data if the text contains "Regards" or any other word that has rds in it. Tried adding a space before but that would exclude the cases where the text starts with rds.

 

Any idea would be helpful 

 

Thanks !

  • Hi QWERTYZ .

    Try this formula :

    CountRds = CALCULATE(COUNTROWS('Table'),find("rds ",'Table'[TEST],1,0)>0 || LEFT('Table'[TEST],3)= "rds" || find(" rds",'Table'[TEST],1,0)>0 )

    If this post helps, please Accept it as Solution to help other members find it.

4 Replies

  • Hi QWERTYZ 

    I'm not quite sure what you're trying to accomplish.

    Could you please attach a sample of the data?
    It would be helpful if you could specify exactly what you want the lines to count.
    You say you want to count everything containing RDS, but you also say some words should be excluded.
    The logic behind what is required is unclear to me.

    • QWERTYZ's avatar
      QWERTYZ
      New Member

      Hi,

       

      For example I have these rows:

       

      #  Field1

      1  I will talk to him. Best regards

      2  will go and play billiards

      3  having issues with rds

      rds has been removed

       

      Want to filter only the rows that contain "rds" so it should match only rows 3 & 4. Not 1 & 2 (Regards, billiards). It is a stand alone word.

       

      So I can either display only the rows I need or add a card that counts occurances.

       

      Sorry if I was not clear enough

      • Ritaf1983's avatar
        Ritaf1983
        Super User

        Hi QWERTYZ .

        Try this formula :

        CountRds = CALCULATE(COUNTROWS('Table'),find("rds ",'Table'[TEST],1,0)>0 || LEFT('Table'[TEST],3)= "rds" || find(" rds",'Table'[TEST],1,0)>0 )

        If this post helps, please Accept it as Solution to help other members find it.

  • v-jingzhang's avatar
    v-jingzhang
    Community Support

    Hi QWERTYZ 

     

    You can create a measure to count the rows. 

    Measure = COUNTROWS(FILTER('Table (2)', CONTAINSSTRING('Table (2)'[Column]," rds") || LEFT('Table (2)'[Column],3)="rds"))

    But this measure doesn't exclude words like "rdse". 

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.