Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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.

1 ACCEPTED SOLUTION

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

 

View solution in original post

6 REPLIES 6
Mariusz
Community Champion
Community 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
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.

Capture.PNG

 

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] ) )

Capture.PNG

 

PBIX as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Thank you for your answer @v-frfei-msft 

 

It is an interresting way to solve the problem. But i am trying to avoid using a slicer.

 

@Mariusz  Thank you for your anwser it was just what i was looking for. I appreciate that you gave an example with both a measure and a coulmn.

 

Not to be rude but is there a way to filter the other way around so that it excludes a tag instead of only searching for one tag?

I need to use it the other way around in another report.

 

Again thank you for your answers.

Hi @Anonymous 

 

Sure, all you need to do is replace ">" with "=" like below.

Column = 
IF( 
    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

 

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

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.