Forum Discussion

Del235's avatar
Del235
Helper III
8 months ago
Solved

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? 

  • 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.

10 Replies

  • 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.
  • 123abc's avatar
    123abc
    Community Champion

     

    If you only want to filter in a visual, do this:

    Steps

    1. Select the visual.

    2. Go to the Filters pane → find your Email Address field.

    3. Change filter type to Advanced filtering.

    4. Add these three conditions:

    Email Address → does not start with → no-email
    Email Address → does not start with → gmail
    Email Address → does not start with → sbcglobal

    Important

    • Click "Add filter clause" to add multiple conditions.

    • Change the logic to AND so that all three exclusions apply.

    Your filter will look like:

    Field Operator Value
     
    Email Addressdoes not start withno-email
    ANDdoes not start withgmail
    ANDdoes not start withsbcglobal

     

    Let me know if you want to use file anyother way.

  • Hi,

     

    You can also build a Column to filter them out and this would be simpler way for maintenance in future. 

    IsValid =
    VAR _e = LOWER ( TRIM ( Table1[Email] ) )
    RETURN
    NOT (
        LEFT(_e, 8) = "no-email"
        || LEFT(_e, 5) = "gmail"
        || LEFT(_e, 9) = "sbcglobal"
    )

     

  • If you have email column then simply 

    Select Email and then go to advance filtering 
    select email starts with 
    no-email,

    does not begin with   no-email

    AND

    does not begin with   gmail

    AND

    does not begin with   sbcglobal





     


    gmail
    sbcglobal



  • Use Advanced filtering on your Email column and stack three “does not start with” conditions combined with AND.

    Setup:

    1. Put Email field in the Filters pane (visual, page, or report level).

    2. Choose Advanced filtering.

    3. Add three rules:

      • “does not start with” → no-email

      • “does not start with” → gmail

      • “does not start with” → sbcglobal

    4. Make sure the logical operator between them is AND

  • Hi Del235 

     

    > Option 1: Advanced Filter (Recommended – No DAX)

    Select your Table / Visual

    Go to the Filters pane

    Drag the Email Address column into Filters on this visual

    Change filter type to Advanced filtering

    Set conditions as:

    Show items when value:
    does not start with no-email
    AND
    does not start with gmail
    AND
    does not start with sbcglobal


    📌Make sure you use AND, not OR
    📌This keeps only emails that do not start with those values

    ✔ Example:

    [email protected]
    [email protected]

    x Example removed:
    [email protected]
    [email protected]
    [email protected]

     

    > Option 2: DAX Calculated Column (More Control)

    Use this if you want the logic reusable across visuals.

    Valid Email =
    IF (
    LEFT ( LOWER ( Table[Email] ), 8 ) = "no-email"
    || LEFT ( LOWER ( Table[Email] ), 5 ) = "gmail"
    || LEFT ( LOWER ( Table[Email] ), 9 ) = "sbcglobal",
    "Exclude",
    "Include"
    )


    Then filter:

    Valid Email = Include

     

    > Option 3: Power Query (Best for Large Datasets)

    Open Transform Data

    Select Email column

    Filter → Text Filters → Does Not Begin With

    Apply three filters:

    does not begin with no-email

    does not begin with gmail

    does not begin with sbcglobal

    Power Query is best for performance and data cleansing

     

    Please give headsup / mark it as a solution once it is comepleted. Thank You!

  • Hi Del235 ,

    This can be done cleanly in Power BI, and the best approach depends on whether you want it at data-load time or report-interaction time.

    Recommended approach (Power Query – best practice)

    If these emails should always be excluded, do this in Power Query.

    Steps

    Open Transform data

    Select the column with the email addresses

    Go to Home → Filter → Text Filters → Does Not Begin With

    Add the following conditions:

    does not begin with no-email

    does not begin with gmail

    does not begin with sbcglobal

    Combine them using AND

    This permanently removes those records from the model.

    Equivalent M code
    = Table.SelectRows(
    Source,
    each not (
    Text.StartsWith([Email], "no-email")
    or Text.StartsWith([Email], "gmail")
    or Text.StartsWith([Email], "sbcglobal")
    )
    )

    🔁 Alternative: Advanced Filter in the report (no data removal)

    If you want to keep the data but filter it visually:

    Select the visual

    Go to the Filters pane

    Add the Email field

    Choose Advanced filtering

    Configure:

    does not begin with no-email

    AND does not begin with gmail

    AND does not begin with sbcglobal

    This affects only the visual or page, not the dataset.

    What not to do

    Avoid using CONTAINS or SEARCH for this case

    Avoid creating calculated columns unless absolutely necessary

    Don’t rely on slicers for exclusion logic like this

    Conceptual illustration
    Email List
    ├── [email protected] filtered out
    ├── [email protected] filtered out
    ├── sbcglobal_user@... filtered out
    └── [email protected] kept

    Summary

    ✔ Use Power Query if the rule is permanent
    ✔ Use Advanced Filters if it’s report-level logic
    ✔ Use Does Not Begin With + AND conditions

    If this helped, please consider giving a kudos 👍
    And if it solved your problem, feel free to mark this as the Accepted Answer ✔

  • v-aatheeque's avatar
    v-aatheeque
    Community Support

    Hi Del235 

    Following up to confirm if the earlier responses addressed your query. If not, please share your questions and we’ll assist further.

    • v-aatheeque's avatar
      v-aatheeque
      Community Support

      Hi Del235 

      Have you had a chance to look through the responses shared earlier? If anything is still unclear, we’ll be happy to provide additional support.

  • Del235 Hey,

     Visual-level filter: applies to one visual
    - Page-level filter: applies to all visuals on the page
    - Report-level filter: applies to the entire report

    Steps
    1) Drag your Email field into the Filters pane (at the desired scope).
    2) Change the filter type to Advanced filtering.
    3) Set the condition group to And.
    4) Add these clauses:
    - does not start with → no-email
    - does not start with → gmail
    - does not start with → sbcglobal
    5) (Optional) Add is not blank to exclude blanks.

    Notes and tips

    • The text match is case-insensitive. If you have leading spaces in the data, trim them in Power Query (Transform > Format > Trim/Clean).
    • If what you actually mean is to exclude Gmail/SBCGlobal by domain, use:


    - does not end with → @gmail.com
    - does not end with → @sbcglobal.net
    or use does not contain with those domain endings.

    This will filter out any email addresses that begin with those strings (or those domains, if you use the alternative).



    Thanks

    Haish K 

    If I resolve your issue. Kindly give kudos to this post and accept it as a solution so other can refer this.