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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
bkwohls
Helper I
Helper I

Find Customers who did NOT puchase X product(s)

As a FNG to PBI:

I have used the DAX formula below successfully to determine customers who have NOT purchased a specific product. What I NEED to do is correct this DAX to allow for the selection of multiple products. When multiple values are selected in my slicer I get an error

For Context

'Sales 4y' is my Sales Table

'Part DNS' is my list of Parts that I want to use as my DID NOT SELL list for use in a slicer

 

DID NOT SELL =
CALCULATE ( [Total Sales], FILTER ( 'Sales 4y', NOT ( CONTAINS ( 'Sales 4y', 'Sales 4y'[PartNum], VALUES ( 'Part DNS'[PartNum] ) ) ) )
 
The end visual is a Simple Table that shows the Total Sales for the Customers who did not purchase the selected items. Customer Name is in the Sales 4Y table. 
1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

@bkwohls 

DID NOT SELL =
VAR slicerVals_ =
    VALUES ( 'Part DNS'[PartNum] )
VAR customerList_ =
    EXCEPT (
        DISTINCT ( 'Sales 4y'[CustomerID] ),
        CALCULATETABLE (
            DISTINCT ( 'Sales 4y'[CustomerID] ),
            FILTER ( 'Sales 4y', 'Sales 4y'[PartNum] IN slicerVals_ )
        )
    )
RETURN
    CALCULATE ( [Total Sales], customerList_ )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

View solution in original post

7 REPLIES 7
bkwohls
Helper I
Helper I

Brilliant - Many thanks!

Anonymous
Not applicable

Hi @bkwohls ,

Could you please mark the helpful post as Answered if the problem has been resolved? It will help other members in the community find the solution easily if they face the similar problem with you. Thank you.
Best Regards
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.

AlB
Community Champion
Community Champion

Hi @bkwohls 

I don't follow completely but based on your current measure, try this:

DID NOT SELL =
VAR slicerVals_ =
    VALUES ( 'Part DNS'[PartNum] )
RETURN
    CALCULATE (
        [Total Sales],
        FILTER ( 'Sales 4y', NOT 'Sales 4y'[PartNum] IN slicerVals_ )
    )

 You might need an ALL('Sales 4y') as based for the filter or something else depending on how/where you use the measure

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

This works to display the sales for a customer that are not in the Did Not Sell list, However I want the [Total Sales] for the customers that never sold the part.

AlB
Community Champion
Community Champion

@bkwohls 

DID NOT SELL =
VAR slicerVals_ =
    VALUES ( 'Part DNS'[PartNum] )
VAR customerList_ =
    EXCEPT (
        DISTINCT ( 'Sales 4y'[CustomerID] ),
        CALCULATETABLE (
            DISTINCT ( 'Sales 4y'[CustomerID] ),
            FILTER ( 'Sales 4y', 'Sales 4y'[PartNum] IN slicerVals_ )
        )
    )
RETURN
    CALCULATE ( [Total Sales], customerList_ )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

amitchandak
Super User
Super User

@bkwohls , Not very clear. But you use this meausre with customer and product if will give product not purcahsed by customer. You can use slicer filter too

not sold measure =

if(isblank( [Total Sales]),1,blaknk())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

In 'Sales 4Y' Table I have fields Partnum,Customer, Sales $,Date. In 'Part DNS' table it is just a list of part numbers with no relation to Sales table. I want to use 'Part DNS' table as a slicer for user to select the part(s) to find customer who did not sell them. Is that more clear? How can I make more clear?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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