Double Condition (where sumproduct won't work)

Guanjin Peter

Active Member
Joined
May 21, 2008
Messages
429
my table is something like below:
my program sheet looks something like this:
I need a double condition formula to check the date, if matches the date Column (A), and matches product Column (b), then returns Column (C) which is the doc#.
I Could easily do it if it is a sum product formula, but in this case, it is alpha numberic.

date: 14 Jun (dd / mm)
product -- Doc#
apple ---- ac21 (so what formula do I put here?)
Orange --- abc2 (formula?)


date --- product --- Doc#
12 Jun -- apple ----- abc1
12 Jun -- Orange --- ab12
14 JUn -- Apple ----- ab21
14 Jun -- Orange ---- abc2
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
=SUMPRODUCT(--(db!A$2:A$10=B2),--(db!D$2:D$10=B9),db!K$2:K$10)
I put a new clumn K as index: 1,2,3,4,5,6,7
>>> This formula returns the values of added up values of K, so I can't effectively get the row number.

=INDEX(db!H2:H7,IF(MATCH(B11,db!D2:D7,0)=MATCH(B2,db!A2:A7,0),MATCH(B2,db!A2:A7,0),""))
>>> Was trying to makes 2 MATCH formula to match then return row number. Didn't work too.

If I can get the row number via 2 conditional matches(returns the 1st row number with simliar entries)....it should be really easy.
 
Last edited:
Upvote 0
Hi Peter_SSS, Sorry for late reply. I just checked. Can assume Doc# will be the same it date and product is the same. So it means by table assumption is wrong. So it should be like this:

<TABLE style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 10pt; FONT-FAMILY: Arial,Arial; BACKGROUND-COLOR: #ffffff" cellSpacing=0 cellPadding=0 border=1><TR style="FONT-WEIGHT: bold; FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center"><TD></TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD><TD>E</TD><TD>F</TD><TD>G</TD><TD>H</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">1</TD><TD style="TEXT-ALIGN: right">date </TD><TD></TD><TD></TD><TD>product</TD><TD></TD><TD></TD><TD></TD><TD>Doc#</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">2</TD><TD style="TEXT-ALIGN: right">12-Jun</TD><TD></TD><TD></TD><TD>Apple</TD><TD></TD><TD></TD><TD></TD><TD>abc1</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">3</TD><TD style="TEXT-ALIGN: right">12-Jun</TD><TD></TD><TD></TD><TD>Orange</TD><TD></TD><TD></TD><TD></TD><TD>ab12</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">4</TD><TD style="TEXT-ALIGN: right">14-Jun</TD><TD></TD><TD></TD><TD>Apple</TD><TD></TD><TD></TD><TD></TD><TD>ab21</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">5</TD><TD style="TEXT-ALIGN: right">14-Jun</TD><TD></TD><TD></TD><TD>Orange</TD><TD></TD><TD></TD><TD></TD><TD>abc2</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">6</TD><TD style="TEXT-ALIGN: right">14-Jun</TD><TD></TD><TD></TD><TD>Apple</TD><TD></TD><TD></TD><TD></TD><TD>ab21</TD></TR></TABLE>

But doc# can be different, if date is different but same product.
I'm really sorry Peter for the changes, I didn't expect this until now.
In that case use Aladin's formula:

Excel Workbook
ABCDEFGHI
1dateproductDoc#
212-JunAppleabc1
312-JunOrangeab12
414-JunAppleab21
514-JunOrangeabc2
614-JunAppleab21
7
db




Excel Workbook
ABCDE
1dateDoc#
214-Junab21
3
4
5
6
7
8product
9Apple
10
Match multiple
 
Upvote 0
thank you so much! That solves it! :>
Should have tried that formula again...:(


Well, I'm finally one happy tiger now.
 
Upvote 0
Hmm...if it is invalid it'll show #N/A, the puzzling thing is, when I search Column C to replace #N/A with "", it says it found none! Am I missing something?
 
Upvote 0
Hmm...if it is invalid it'll show #N/A, the puzzling thing is, when I search Column C to replace #N/A with "", it says it found none! Am I missing something?
What does it have to do with column C? I thought we were using columns A, D and H!

As pointed out earlier, #N/A will occur if the date and product combination does not occur on the "db" sheet.

That is, given my small sample sheets, you will get #N/A if ...
a) B2 or B9 on the formula sheet is blank, or
b) the date/product combination on the formula sheet does not exist on the "db" sheet. For my small sample, try putting "zzz" in B9 and you will see.
 
Upvote 0
hmm okay. Sorry was testing out random things, so I tried on column C. Can I return a "" value if not found? Or is it possible to replace the whole column of #N/A with ""?
 
Upvote 0
... is it possible to replace the whole column of #N/A with ""?
What column of #N/A? :confused: You said previously
when I search Column C to replace #N/A with "", it says it found none!


Can I return a "" value if not found?
Sure, here's one way:

=IF(ISNA(LOOKUP(2,1/((db!A1:A13=B2)*(db!D1:D13=B9)),db!H1:H13)),"",LOOKUP(2,1/((db!A1:A13=B2)*(db!D1:D13=B9)),db!H1:H13))
 
Upvote 0
What column of #N/A? :confused: You said previously


Sure, here's one way:

=IF(ISNA(LOOKUP(2,1/((db!A1:A13=B2)*(db!D1:D13=B9)),db!H1:H13)),"",LOOKUP(2,1/((db!A1:A13=B2)*(db!D1:D13=B9)),db!H1:H13))

Peter,

The following should be less expensive:
Code:
=LOOKUP(REPT("z",255),
   CHOOSE({1,2},
     "",
     LOOKUP(2,1/((db!A1:A13=B2)*(db!D1:D13=B9)),db!H1:H13)))
 
Upvote 0
Peter,

The following should be less expensive:
Code:
=LOOKUP(REPT("z",255),
   CHOOSE({1,2},
     "",
     LOOKUP(2,1/((db!A1:A13=B2)*(db!D1:D13=B9)),db!H1:H13)))
Thanks Aladin - clever thinking - as usual.
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,669
Members
449,248
Latest member
wayneho98

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