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
Anonymous
Not applicable

How do I identify customers, who never bought an Item of specific cateogry?

Hi,

 

we have the following table: 

 

CustomerItemCategory
ATicket
AMerchandise
BMerchandise
CTicket

 

This table has more then a thousand entries. I would like to filter all the customers who never bought an Item from the Ticket category. In this case, It should return B, as this customer only bought merchandise.

 

Any tips on how to achieve that?

1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please create a measure like this.

Measure = 
VAR x =  
CALCULATE(
    COUNT(Sheet2[ItemCategory]),
    FILTER(
       ALL(Sheet2),
        Sheet2[Customer] = MAX(Sheet2[Customer]) && Sheet2[ItemCategory] = "Ticket"
    )
)
RETURN
IF(
    x = BLANK(),
    MAX(Sheet2[Customer])
)

p3.PNG

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

5 REPLIES 5
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please create a measure like this.

Measure = 
VAR x =  
CALCULATE(
    COUNT(Sheet2[ItemCategory]),
    FILTER(
       ALL(Sheet2),
        Sheet2[Customer] = MAX(Sheet2[Customer]) && Sheet2[ItemCategory] = "Ticket"
    )
)
RETURN
IF(
    x = BLANK(),
    MAX(Sheet2[Customer])
)

p3.PNG

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

 

You can also try this measure

 

 

Customer who didn't by  Ticket =
VAR allcustomers =
    VALUES ( 'Table'[Customer] )
VAR BoughtTicket =
    CALCULATETABLE (
        VALUES ( 'Table'[Customer] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[ItemCategory] = "Ticket"
        )
    )
RETURN
    COUNTROWS (
        EXCEPT (
            allcustomers,
            BoughtTicket
        )
    )

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

You can try this measure.

 

Measure =

VAR Cond1=Countrows(VALUES('Table'[Customer]))
VAR Cond2=Countrows(CALCULATETABLE(VALUES('Table'[Customer]),Filter(ALL('Table'[ItemCategory]),'Table'[ItemCategory] IN {"Ticket"})))
RETURN
If(AND(Cond1>=1,Cond2=0),"Yes","No")
 
 
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
mahoneypat
Employee
Employee

A measure like this should work for you

 

Customers who did not buy tickets =
COUNTROWS (
    FILTER (
        VALUES ( Table[Customer] ),
        ISBLANK ( CALCULATE ( COUNT ( Table[Category] ) ) )
    )
)

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


nvprasad
Solution Sage
Solution Sage

Hi

 

Can you try below.

 

CustomerCount(ExceptTicket) =
CALCULATE ( COUNTROWS ( Customer ), Customer[ItemCategory] <> "Ticket" )

Regards,

Venkata Nalla

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.