Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Filter a value based on a word in a string

Hello Everyone

I am trying to create a mesaure that filters a value based on a word in a text string. The string i build like this "WordA, WordB, WordC, WordD" The word i want to filter is showing up in random places for every row.

I have tried different things and it is not working for me.

Any help is greatly apprenticed.

  • Mariusz's avatar
    Mariusz
    6 years ago

    Hi Anonymous 

     

    Please see the below.

    Column = 
    IF( 
        SEARCH( "WordC", 'Table'[Text], 1, 0 ) > 0, 
        'Table'[Value] 
    )
    Measure = 
    SUMX( 
        FILTER(
            'Table',
            SEARCH( "WordC", 'Table'[Text], 1, 0 ) > 0 ),
        'Table'[Value]
    )
    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    Mariusz Repczynski

     

6 Replies

  • Mariusz's avatar
    Mariusz
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 

     

    Can you create a data sample and explain if you are looking for a specific fixed word or do you want to select the word from the slicer?

     

    Best Regards,
    Mariusz

    Please feel free to connect with me.
    Mariusz Repczynski

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Mariusz 

       

      Thank you for your answer 

      and sorry for not being specific enough

      Yes i am looking for a specific fixed word every time.

       

      I made a table to better explane it

      values that contains WordC get copyed over to a new coulmn.

       

      • v-frfei-msft's avatar
        v-frfei-msft
        Icon for Community Support rankCommunity Support

        Hi Anonymous ,

         

        We can make it dynamicly by creating a measure based on a slicer.

        Measure = 
        VAR a =
            SEARCH ( SELECTEDVALUE ( Slicer[Filter] ), MAX ( 'Table'[Text] ),, BLANK () )
        RETURN
            IF ( a = BLANK (), BLANK (), MAX ( 'Table'[Value] ) )
        

         

        PBIX as attached.