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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Bebs
Helper II
Helper II

Dax Function to filter on a field, not a scalar value

Hi,

In Dax, I would like to filter a column with the values of another column.

exemple : In a table If I've 2 columns CustomerName and ProductName.  also I've CustomerNameWhiteList  wich is a table/column result of a DAX Calculation.
I would like to get ProductName where CustomerName is not in a CustomerNameWhiteList

How can I do that ?


Another way to see the problem : I'd like to filter columns of a table using not a scalar value but all values of another field, How can I do that ?

 

Thanks

 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @Bebs ,

 

the measure below returns a table, the funtion CONCATENATEX is only used to transform the table into a string:

Measure = 
var ProductsWhitelistedCustomers = 
    DISTINCT(
        SELECTCOLUMNS(
            FILTER(
                SUMMARIZE(
                    'Table'
                    , 'Table'[Products]
                    , 'Table'[CustomersWhitelist]
                )
                , 'Table'[CustomersWhitelist] <> BLANK()
            )
            , "PnotWhitelisted" , 'Table'[Products]
        )
    )
var ProductCustomers = 
    DISTINCT(
        SELECTCOLUMNS(
            SUMMARIZE(
                'Table'
                , 'Table'[Products]
                ,'Table'[all customers]
            )
            , "Products" , 'Table'[Products]
        )
    )
return
CONCATENATEX(
    EXCEPT( ProductCustomers , ProductsWhitelistedCustomers )
    , [Products]
    , ", "
)

The screenshot below shows my "table" and a Card visual that is visualizing the measure:
image.png

Hopefully, this provides you an idea of how tackle your challenge.

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

3 REPLIES 3
TomMartens
Super User
Super User

Hey @Bebs ,

 

you can not use SUMMARIZE with disconnected tables. Here you will find a description of SUMMARIZE: SUMMARIZE – DAX Guide

 

To avoid any further misunderstandings I recommend that you create a pbix file that contains sample data but still reflects your semantic model (tables, relationships, calculated columns, and measures). Upload the pbix to OneDrive, Google Drive, or Dropbox, and share the link in this thread. If you are using a spreadsheet to create the sample data instead of the manual input mehtod, share the spreadsheet as well.

 

Do not forget to describe the expected result based on the sample data you provide.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Bebs
Helper II
Helper II

Thanks for your suggestion, can you please explain the SUMMARIZE part ? I don't understand what happens when we SUMMARIZE two different tables unlinked ?

TomMartens
Super User
Super User

Hey @Bebs ,

 

the measure below returns a table, the funtion CONCATENATEX is only used to transform the table into a string:

Measure = 
var ProductsWhitelistedCustomers = 
    DISTINCT(
        SELECTCOLUMNS(
            FILTER(
                SUMMARIZE(
                    'Table'
                    , 'Table'[Products]
                    , 'Table'[CustomersWhitelist]
                )
                , 'Table'[CustomersWhitelist] <> BLANK()
            )
            , "PnotWhitelisted" , 'Table'[Products]
        )
    )
var ProductCustomers = 
    DISTINCT(
        SELECTCOLUMNS(
            SUMMARIZE(
                'Table'
                , 'Table'[Products]
                ,'Table'[all customers]
            )
            , "Products" , 'Table'[Products]
        )
    )
return
CONCATENATEX(
    EXCEPT( ProductCustomers , ProductsWhitelistedCustomers )
    , [Products]
    , ", "
)

The screenshot below shows my "table" and a Card visual that is visualizing the measure:
image.png

Hopefully, this provides you an idea of how tackle your challenge.

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.