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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Asantos2020
Advocate II
Advocate II

Multiple Slicers + Filter Customer who haven't bought selected item (in DAX)

Hello!

 

I have the following problem I can't get my head around and ended up here to ask for your help:

 

Slicer 1: Year (from a Calendar Table)

Slicer 2: Month (from a Calendar Table)

Slicer 3: Customer Category (From Sales Table, whose Date Column is related to Calendar Date)

Slicer 4: Product (separate table, summarized from Sales Table)

 

When the user selects Year, Month, Customer Category and the Product, the table below them should list the customers who have not bought that product within that period of time. 

Currently, the table lists the customers who haven't bought the product, but only the ones we sold something to and didn't include the selected item. Instead, it should list all of the customers who have not bought that item in the selected period of time.

Here is the DAX formula used for now:

Customers who didn't buy = IF(
HASONEVALUE(Product[Object]);
CALCULATE(
DISTINCTCOUNT(Sales Table[CustomerID]);
FILTER(
Sales Table;
NOT(CONTAINS(Sales Table;Sales Table[Object];VALUES(Products[Object])))
)
);
DISTINCTCOUNT(Sales Table[CustomerID])
)

Any help is greatly appreciated!

1 ACCEPTED SOLUTION

Hi @Asantos2020 ,

 

Sorry for missing the key point. We can achieve that by two ways.

 

1. To create a calculated table and work on that by a measure.

new sales = Sales
new filer = 
VAR a =
    VALUES ( 'Product'[Product] )
RETURN
    IF ( MAX ( 'new sales'[Product] ) IN a, BLANK(),1 )

Alternatively, we can create a measure and display the product by a card.

Measure 3 = 
VAR a =
    VALUES ( 'Product'[Product] )
RETURN
    CONCATENATEX (
        CALCULATETABLE (
            DISTINCT ( Sales[Product] ),
            FILTER ( ALL ( Sales ), ( Sales[Product] IN a ) = FALSE () )
        ),
        Sales[Product],
        " "
    )

3.PNG

For more details, please check the pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

5 REPLIES 5
v-frfei-msft
Community Support
Community Support

Hi @Asantos2020 ,

 

To create another measure and make the visual filtered by it as the picture below.

 

Measure 2 = 
VAR a =
    VALUES ( 'Product'[Product] )
RETURN
    IF ( MAX ( Sales[Product] ) IN a, 1, BLANK () )

2.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hello again @v-frfei-msft !

Sorry if this is stretching your "good faith", but there is one more request:

 

The list of customers who didn't buy that item should consist of all the customers in the system, instead of only the ones who bought something that year/month.

How to include that - I wonder.

 

PS: I'm definitely going after a course on DAX, Power BI, etc in the near future, so I can help more than ask for it.

Hi @Asantos2020 ,

 

Sorry for missing the key point. We can achieve that by two ways.

 

1. To create a calculated table and work on that by a measure.

new sales = Sales
new filer = 
VAR a =
    VALUES ( 'Product'[Product] )
RETURN
    IF ( MAX ( 'new sales'[Product] ) IN a, BLANK(),1 )

Alternatively, we can create a measure and display the product by a card.

Measure 3 = 
VAR a =
    VALUES ( 'Product'[Product] )
RETURN
    CONCATENATEX (
        CALCULATETABLE (
            DISTINCT ( Sales[Product] ),
            FILTER ( ALL ( Sales ), ( Sales[Product] IN a ) = FALSE () )
        ),
        Sales[Product],
        " "
    )

3.PNG

For more details, please check the pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
v-frfei-msft
Community Support
Community Support

Hi @Asantos2020 ,

 

To create a measure as below.

 

Measure = 
VAR proj =
    VALUES ( 'Product'[Product] )
VAR infilter =
    CALCULATE (
        DISTINCTCOUNT ( Sales[CustomerID] ),
        FILTER ( Sales, Sales[Product] IN proj )
    )
VAR alno =
    CALCULATE ( DISTINCTCOUNT ( Sales[CustomerID] ), ALL ( Sales ) )
RETURN
    IF ( ISFILTERED ( 'Product'[Product] ), alno - infilter, BLANK () )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hello @v-frfei-msft !

Thanks for taking the time to help.

With the intent to confirm, I see below a list of 05 customers, but this includes a customer who did buy P1 in April. Shouldn't we see a list of the ones who bought other items, but the one filtered? 

Capturar.JPG

Again, thank you in advance!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.