8 Replies Latest reply on Oct 28, 2016 11:45 AM by Alexander Mou

# Count Customers who bought Product A and Product B

Hi All, I have tried a few solutions but I'm still relatively new to this.

I need to create a table that calculates the total number of customers who purchased Product A and Product B in separate orders/dates (next challenge will count days between orders)

Example:

QUESTION: How many customers purchased an Orange and an Apple

• ###### 1. Re: Count Customers who bought Product A and Product B

Hello Brett,

For case 1 you can do something like below.

For Case 2, please write in detail.

Regards,

Rav

• ###### 2. Re: Count Customers who bought Product A and Product B

Got that.

I need to be able to discover certain combinations. For example, those who purchased Product A in one order and then Product B on another day. The actual scenario is:

[date] [passengerID] [bookingID] [airlineID]

So how many passengers travelled with Airline B and C or other combination I wish to discover. There is only one airline per bookingID, but a customer can have multiple bookingIDs

• ###### 3. Re: Count Customers who bought Product A and Product B

Here are two posts I wrote that may give you hints on solving your problem.

See if they help.

• ###### 4. Re: Count Customers who bought Product A and Product B

You could filter to get all the customers who bought both.

Create a CONDITION filter on [Customer] that looks like this:

SUM(IF [product] = [Product Parameter 1] THEN 1 ELSE 0 END) > 0

AND

SUM(IF [product] = [Product Parameter 2] THEN 1 ELSE 0 END) > 0

Make two parameters.  Let the user specify the values.

1 of 1 people found this helpful
• ###### 5. Re: Count Customers who bought Product A and Product B

Hello,

Is that what you wanted?

Thanks,

Devansh

• ###### 6. Re: Count Customers who bought Product A and Product B

Hie,

I have created a calculated field with No of customers in that this is the calculation I had created

IF attr([Product])='Apple' then count([Order No])

ELSEif attr([Product])='Orange' THEN count([Order No])

ELSE count([Order No])

END

• ###### 7. Re: Count Customers who bought Product A and Product B

Hi,

If you just need a cross table of products and count of distinct customers then you may use this simple solution:

index is addressed so that it densifies marks for each product combination (with a purchase)

count is computed along customer and it yields the value you need

Łukasz

5 of 5 people found this helpful
• ###### 8. Re: Count Customers who bought Product A and Product B

@Łukasz

This is an amazing solution. I used to do it using custom sql. I like the way you did using data densification.

I wrote a note to document the details.