0
votes

Considering the following data :

sheet1 (customers)

  A
0 customer_name
1 john
2 kevin
3 mickael

sheet2 (products)

  A
0 product_name
1 book
2 ball
3 game

sheet3 (orders)

  A             B
0 customer_name product_name
1 john          book
2 john          game
3 mickael       ball

I would like to know for each combination of customer and product if an order has been ordered and display it in the sheet1 to get something like that :

sheet1 (customers updated )

  A              B    C    D    
0 customer_name  book ball game
1 john           1    0    1
2 kevin          0    0    0
3 mickael        0    1    0

I know how to do that with "code" (by doing a macro in vba or a small exe in c# that will update the file), but I want to do it (if its possible) by just setting a formula inside my sheet (fyi, I can put the 3 inputs in the same sheet if needed, that's not a constraint

Updated :

with the previous configuration described, I have put the following formula in sheet1 B2 : =COUNTIFS(Sheet3!$A:$A;$A2;Sheet3!$B:$B;B$2), and when running the formula and extending it to every cell in my sheet I am getting everywhere the value #NAME? (I've translated if from french so I am not sure if its the right error in english). I think where I am making a mistake is that I am not using sheet2, how can I say first to "do all the combinations possible of customers insheet1 and products in sheet2 and look for those combinations in sheet3, knowing that I am in sheet1 and that I want to display the result like aking before?

1
If you can put the 3 inputs in the same sheet, then use COUNTIFS. - BigBen
I will have to add a formula for each combination possible, there is no way to make something dynamically that will make all the combinations possible between customers and products? - bssyy78
Use absolute referencing and reference the customer name column and the product name row... =COUNTIFS(Sheet2!$A:$A,$A1,Sheet2!$B:$B,B$1). Or use a pivot table. - BigBen
will it be possible to have a more detailled answer? - bssyy78
Can you try that formula? - BigBen

1 Answers

1
votes

Use COUNTIFS:

=COUNTIFS(Sheet3!$A:$A,$A2,Sheet3!$B:$B,B$1)

enter image description here