Forum Discussion
Del235
8 months agoHelper III
Advanced filters
I have a list of email addresses. I want to filter out addresses that start with no-email, gmail and sbcglobal. How would I setup the Advanced Filter in Power BI?
- 8 months ago
Hi Del235, where exactly do you want to filter them out? On page level, inside a measure, or in Power Query already?
Power Query:if Text.StartsWith(Text.Lower([Email]), "no-email") or Text.StartsWith(Text.Lower([Email]), "gmail") or Text.StartsWith(Text.Lower([Email]), "sbcglobal") then 0 else 1- You can then either filter the rows in Power Query already for [YourColumnName] = 1 or apply it as a filter via the filter pane after loading it into your model.
DAX (assuming that you literally mean that those should be the first few characters in the column and you know that there won't be any other characters before the parts you're looking for):
IsValidEmail = IF ( LEFT ( LOWER ( 'Table'[Email] ), 8 ) = "no-email" || LEFT ( LOWER ( 'Table'[Email] ), 5 ) = "gmail" || LEFT ( LOWER ( 'Table'[Email] ), 9 ) = "sbcglobal", 0, 1 )
As a Filter in the Filter-Pane:- Switch column to "Advanced filtering" and use "does not start with" (you can drag + drop the same column multiple times into the filter pane to apply it for all three terms
OR - Create a Measure with the DAX-Example above, drag it into the filter pane and filter for IsValidEmail = 1.
- You can then either filter the rows in Power Query already for [YourColumnName] = 1 or apply it as a filter via the filter pane after loading it into your model.
KarinSzilagyi
8 months agoSuper User
Hi Del235, where exactly do you want to filter them out? On page level, inside a measure, or in Power Query already?
Power Query:
if
Text.StartsWith(Text.Lower([Email]), "no-email")
or Text.StartsWith(Text.Lower([Email]), "gmail")
or Text.StartsWith(Text.Lower([Email]), "sbcglobal")
then 0 else 1- You can then either filter the rows in Power Query already for [YourColumnName] = 1 or apply it as a filter via the filter pane after loading it into your model.
DAX (assuming that you literally mean that those should be the first few characters in the column and you know that there won't be any other characters before the parts you're looking for):
IsValidEmail =
IF (
LEFT ( LOWER ( 'Table'[Email] ), 8 ) = "no-email"
|| LEFT ( LOWER ( 'Table'[Email] ), 5 ) = "gmail"
|| LEFT ( LOWER ( 'Table'[Email] ), 9 ) = "sbcglobal",
0,
1
)
As a Filter in the Filter-Pane:
- Switch column to "Advanced filtering" and use "does not start with" (you can drag + drop the same column multiple times into the filter pane to apply it for all three terms
OR - Create a Measure with the DAX-Example above, drag it into the filter pane and filter for IsValidEmail = 1.