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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Sullyball2a
Frequent Visitor

Simplify DAX to get a listing of customers

I have a table where there are multiple customer records Table 1 and a table of customers I want to exclude from my results Table2. Tables 1 & 2 are joined in my data model: many to one.

I want a listing (no duplicates) of customers from Table 1 not in Table 2

The DAX I have written to achieve this is:

DEFINE

 VAR MyDetailTbl =

 CALCULATETABLE(

    SELECTCOLUMNS('Table 1'

    ,"Customer Number", 'Table 1'[Customer No]

    ,"isDup", RELATED(Table2[Customer No])

    )

)

 

VAR MySummaryTbl =

GROUPBY(MyDetailTbl, [Customer Number],[isDup])

 

EVALUATE

SELECTCOLUMNS(FILTER(MySummaryTbl, ISBLANK([isDup])),"Customer No", [Customer Number])

 

This seems over complicated. Is there a more straightforward way to achieve this?

2 ACCEPTED SOLUTIONS
Selva-Salimi
Super User
Super User

Hi @Sullyball2a ,

 

Yes, you can rewrite it as follows :

 

except( distinct('Table 1'[Customer No]), distinct( 'MyDetailTbl'[Customer Number]))

 

If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly. 

 

View solution in original post

Sullyball2a
Frequent Visitor

Thank you  - I knew there had to be a more simple way. I wasn't aware of the EXCEPT() or DISTINCT() functions. I was aware of VALUES() and I tried it with that instead of DISTINCT() and it worked too.

View solution in original post

2 REPLIES 2
Sullyball2a
Frequent Visitor

Thank you  - I knew there had to be a more simple way. I wasn't aware of the EXCEPT() or DISTINCT() functions. I was aware of VALUES() and I tried it with that instead of DISTINCT() and it worked too.

Selva-Salimi
Super User
Super User

Hi @Sullyball2a ,

 

Yes, you can rewrite it as follows :

 

except( distinct('Table 1'[Customer No]), distinct( 'MyDetailTbl'[Customer Number]))

 

If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly. 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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