Calculate correct value based on multiple column criteria

JKER

New Member
Joined
Aug 9, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello,

Below is a condensed table of an orderbook I am currently working on. Each row represents an order. An order consists of an assigned customer, the ordered item, and whether the customer requires special service (indicated by 50/100). The total orderbook contains multiple identical items, but being ordered by multiple customers.

Customer (column A)Item (column B)Required service (column C)Output (column D)
StarA22EM100
StarA22EM50
G20 automationA22IP100
G20 automationA22IP50
G10 automation corp.A22IP100
YSAUA66AA50
YSAUA77RT100
Fest KGA77RT100
TR RoboticsA77RT50
Pakvol GmbHA80GM50
Pakvol GmbHA80GM100
Pakvol GmbHA80GM50
TR RoboticsA80GM100
Sau Corp.A80GM50
Sau Corp.A80GM50
Sau Corp.A80GM100
Pakvol GmbHA80GM100
RC RoboticsA48ZX100
Int. Corp.A33WB50

For each item (row), I want to know whether there are more than one distinct customers requiring a '100' service. More specifically: column D should contain a value:
1; if there are more than one customers requiring a '100' service customer
0; if there is only one (or none) customer requiring a '100' service.

So, the following should be created (column D has been manually calculated):

Customer (column A)Item (column B)Required service (column C)Output (column D)
StarA22EM1000
StarA22EM500
G20 automationA22IP1001
G20 automationA22IP501
G10 automation corp.A22IP1001
YSAUA66AA500
YSAUA77RT1001
Fest KGA77RT1001
TR RoboticsA77RT501
Pakvol GmbHA80GM1001
Pakvol GmbHA80GM501
Pakvol GmbHA80GM501
TR RoboticsA80GM1001
Sau Corp.A80GM501
Sau Corp.A80GM501
Sau Corp.A80GM1001
Pakvol GmbHA80GM501
RC RoboticsA48ZX1000
Int. Corp.A33WB500


I have tried to calculate column D with Vlookup, and index/match to check for each row whether there are items having >1 customers requiring a '100' service. Also, I tried to sum(countif(...) based on criteria. Unfortunately, I could not manage to create a correct formula. Could you help me out? Thank you.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
Fluff.xlsm
ABCD
1
2StarA22EM1000
3StarA22EM500
4G20 automationA22IP1001
5G20 automationA22IP501
6G10 automation corp.A22IP1001
7YSAUA66AA500
8YSAUA77RT1001
9Fest KGA77RT1001
10TR RoboticsA77RT501
11Pakvol GmbHA80GM501
12Pakvol GmbHA80GM1001
13Pakvol GmbHA80GM501
14TR RoboticsA80GM1001
15Sau Corp.A80GM501
16Sau Corp.A80GM501
17Sau Corp.A80GM1001
18Pakvol GmbHA80GM1001
19RC RoboticsA48ZX1000
20Int. Corp.A33WB500
Data
Cell Formulas
RangeFormula
D2:D20D2=SIGN(COUNTIFS(B:B,B2,A:A,"<>"&A2,C:C,100))
 
Upvote 0
Dear Fluff,

Thank you for your response and the correct solution. You really helped me out!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Dear Fluff,

Sorry to bother you. I think your suggested formula does not hold in all cases. I have added 4 more items to the list and the formula gives (Output):

CustomerItemRequired serviceOutput
TR Corp.G50501
TR Corp.G50501
AAG501000
AAG50500

However, the last column should be:

CustomerItemRequired serviceOutput
TR Corp.G50500
TR Corp.G5050
0
AAG501000
AAG50500

There are indeed 2 distinct customers ordering item 'G50', but only one order requires a '100' service. Therefore, the output should be '0' for all 'G50' items. The output should be '1' for all items, when there are >1 distinct customers requiring a '100' service. So, the output should be the following if only one distinct customer orders an item and requires a '100' service.

CustomerItemRequired serviceOutput
LT Corp.60WT121000
LT Corp.60WT121000
 
Upvote 0
Ok,how about
Excel Formula:
=--(COUNTIFS(B:B,B2,A:A,"<>"&A2,C:C,100)+COUNTIFS(B:B,B2,A:A,A2,C:C,100)>1)
 
Upvote 0
I have the feeling your newly proposed Excel formula is closer to the final solution. However, your formula gives the following output:

CustomerItemRequired serviceOutput
TR Corp.G50501
TR Corp.G50501
AAG501001
AAG501001

It does indeed output '1' when 2 customers require a '100' service, but the condition should hold only for >1 distinct customers. In this case, the correct output should be:

CustomerItemRequired serviceOutput
TR Corp.G50500
TR Corp.G5050
0
AAG501000
AAG501000

In the table below, I changed the values in the 'Required service' column to show you a different scenario and its corresponding correct output.
CustomerItemRequired serviceOutput
TR Corp.G50501
TR Corp.G501001
AAG50501
AAG501001

Do you think an adaptation to your formula can solve this? Thanks in advance.
 
Upvote 0
Ok, how about
Excel Formula:
=--(IFERROR(ROWS(UNIQUE(FILTER($A$2:$A$100,($B$2:$B$100=B2)*($C$2:$C$100=100)))),0)>1)
 
Upvote 0
Solution
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Calculate correct value based on multiple column criteria
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Ok, how about
Excel Formula:
=--(IFERROR(ROWS(UNIQUE(FILTER($A$2:$A$100,($B$2:$B$100=B2)*($C$2:$C$100=100)))),0)>1)
This did the trick. UNIQUE() was required to ensure the formula to work as intended. Thank you!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top