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
Niels_T
Post Patron
Post Patron

How to filter with DAX string that contains x

Hello,

 

How do you filter out string that contains specific words?

 

For example:

 

/de/catalogsearch/.......

 

So everything that contains /de/catalogsearch/ will be filtered out.

2 ACCEPTED SOLUTIONS
PC2790
Community Champion
Community Champion

Hi @Niels_T ,

 

You can do it in Power Query by creating a custom column and using the following code:

 

if Text.Contains([ColumnName], "catalogsearch") then "true" else "false"

You can then filter out the true values to get the desired result.

 

If you want to do it using DAX function, the corresponding code will look like:

 

ColumnName = IF(
	ISERROR(
		SEARCH("catalogsearch", TableName[ColumnName])
	),
	"true",
	"false"
)

I hope this suffice your requirement

View solution in original post

PaulDBrown
Community Champion
Community Champion

@Niels_T 

There are a number of ways of doing this. In my example I have a table with dates, values and a string. The objective is to exclude rows in which the string contains "bc".

If you want to use the filter in the filter pane, you can use something along the lines of:

 

 

Filter out strings containing "bc" = 
VAR Vdates  = VALUES(FactTable[date])
VAR WithBC  = CALCULATETABLE(VALUES(FactTable[date]), 
                FILTER(FactTable, CONTAINSSTRING(FactTable[String], "bc")))
RETURN
COUNTROWS(EXCEPT(Vdates, WithBC))

 

 

And the use this in the filters for the visual in the filter pane setting the desired outcome to 1:

filter.JPG

 

or you can use the measure to filter values using CALCULATE:

 

 

Sum Does not contain "bc" = 
CALCULATE([Sum Values], 
FILTER(FactTable, [Filter out strings containing "bc"] = 1))

 

 

sum excluding.JPG

 

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

2 REPLIES 2
PaulDBrown
Community Champion
Community Champion

@Niels_T 

There are a number of ways of doing this. In my example I have a table with dates, values and a string. The objective is to exclude rows in which the string contains "bc".

If you want to use the filter in the filter pane, you can use something along the lines of:

 

 

Filter out strings containing "bc" = 
VAR Vdates  = VALUES(FactTable[date])
VAR WithBC  = CALCULATETABLE(VALUES(FactTable[date]), 
                FILTER(FactTable, CONTAINSSTRING(FactTable[String], "bc")))
RETURN
COUNTROWS(EXCEPT(Vdates, WithBC))

 

 

And the use this in the filters for the visual in the filter pane setting the desired outcome to 1:

filter.JPG

 

or you can use the measure to filter values using CALCULATE:

 

 

Sum Does not contain "bc" = 
CALCULATE([Sum Values], 
FILTER(FactTable, [Filter out strings containing "bc"] = 1))

 

 

sum excluding.JPG

 

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PC2790
Community Champion
Community Champion

Hi @Niels_T ,

 

You can do it in Power Query by creating a custom column and using the following code:

 

if Text.Contains([ColumnName], "catalogsearch") then "true" else "false"

You can then filter out the true values to get the desired result.

 

If you want to do it using DAX function, the corresponding code will look like:

 

ColumnName = IF(
	ISERROR(
		SEARCH("catalogsearch", TableName[ColumnName])
	),
	"true",
	"false"
)

I hope this suffice your requirement

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.