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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
dnana
Microsoft Employee
Microsoft Employee

Filter single column with multiple conditions (words in a string)

Team,

 

I would like to create a measure to filter this table based on a single column that has multiple conditions. I would like to return NAME that has the words "red" and "green" in STRING column.

 

Screenshot 2022-09-20 183231.png

 

The result:

Screenshot 2022-09-20 183251.png

 

 

Any guidance would be appreciated.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@dnana Try:

Selector Measure = 
  VAR __Name = MAX('Table'[NAME])
  VAR __Table = SUMMARIZE('Table',[NAME],"__STRING",CONCATENATEX('Table',[STRING]))
  VAR __Table1 = ADDCOLUMNS(__Table,"__Red",SEARCH("red",[__STRING],,0),"__Green",SEARCH("green",[__STRING],,0))
  VAR __Names = DISTINCT(SELECTCOLUMNS(FILTER(__Table1,[__Red]>0 && [__Green]>0),"__Name",[NAME]))
RETURN
  IF(__Name IN __Names,1,0)

Put this measure in the visual filters section of your Filters pane and filter for 1.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@dnana Try:

Selector Measure = 
  VAR __Name = MAX('Table'[NAME])
  VAR __Table = SUMMARIZE('Table',[NAME],"__STRING",CONCATENATEX('Table',[STRING]))
  VAR __Table1 = ADDCOLUMNS(__Table,"__Red",SEARCH("red",[__STRING],,0),"__Green",SEARCH("green",[__STRING],,0))
  VAR __Names = DISTINCT(SELECTCOLUMNS(FILTER(__Table1,[__Red]>0 && [__Green]>0),"__Name",[NAME]))
RETURN
  IF(__Name IN __Names,1,0)

Put this measure in the visual filters section of your Filters pane and filter for 1.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thank you Greg! Appreciate the quick response and helping me learn more about DAX.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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