Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default If Function with Multiple Conditions


Using Lookup I want to return a value to a cell based upon 2 conditions,
which can exist in any one of four combinations:
YY
YN
NY
YN

The first letter determines which of two Lookup tables are used (Lookup
High or Lookup Std) the second determines which column in the relevant
Lookup table to use for the value to be returned.

I have the two following expressions each of which returns a correct
value but only if the first letter condition is correct (Y or N).

=IF($F2="YN",((INDEX('Lookup High'!$C$2:$D$45,MATCH(AM2,'Lookup
High'!$C$2:$C$45,),MATCH(BM$1,'Lookup
High'!$C$2:$D$2,)))),IF($F2="YY",(INDEX('Lookup
High'!$E$2:$F$45,MATCH(AM2,'Lookup
High'!$E$2:$E$45,),MATCH(BM$1,'Lookup High'!$E$2:$F$2,)))))

=IF($F2="NN",((INDEX('Lookup STD'!$C$2:$D$45,MATCH(AM2,'Lookup
STD'!$C$2:$C$45,),MATCH(BM$1,'Lookup
STD'!$C$2:$D$2,)))),IF($F2="NY",(INDEX('Lookup
STD'!$E$2:$F$45,MATCH(AM2,'Lookup STD'!$E$2:$E$45,),MATCH(BM$1,'Lookup
STD'!$E$2:$F$2,)))))

When I combine these:

=IF($F2="YN",((INDEX('Lookup High'!$C$2:$D$45,MATCH(AM2,'Lookup
High'!$C$2:$C$45,),MATCH(BM$1,'Lookup
High'!$C$2:$D$2,)))),IF($F2="YY",(INDEX('Lookup
High'!$E$2:$F$45,MATCH(AM2,'Lookup
High'!$E$2:$E$45,),MATCH(BM$1,'Lookup
High'!$E$2:$F$2,))))),IF($F2="NN",((INDEX('Lookup
STD'!$C$2:$D$45,MATCH(AM2,'Lookup STD'!$C$2:$C$45,),MATCH(BM$1,'Lookup
STD'!$C$2:$D$2,)))),IF($F2="NY",(INDEX('Lookup
STD'!$E$2:$F$45,MATCH(AM2,'Lookup STD'!$E$2:$E$45,),MATCH(BM$1,'Lookup
STD'!$E$2:$F$2,)))))

Excel gives the result #VALUE!

Any help in spotting the error would be appreciated.

I would also like to return the value 0 if none of the conditions are
met.

Thanks in advance
Tlosgyl3



--
tlosgyl3
------------------------------------------------------------------------
tlosgyl3's Profile: http://www.excelforum.com/member.php...o&userid=28074
View this thread: http://www.excelforum.com/showthread...hreadid=559277

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default If Function with Multiple Conditions

how about using left and right something like this idea

=VLOOKUP(A3,IF(LEFT(A2)="y",D4:E6,E4:F6),IF(RIGHT( A2)="n",1,2))
--
Don Guillett
SalesAid Software

"tlosgyl3" wrote in
message ...

Using Lookup I want to return a value to a cell based upon 2 conditions,
which can exist in any one of four combinations:
YY
YN
NY
YN

The first letter determines which of two Lookup tables are used (Lookup
High or Lookup Std) the second determines which column in the relevant
Lookup table to use for the value to be returned.

I have the two following expressions each of which returns a correct
value but only if the first letter condition is correct (Y or N).

=IF($F2="YN",((INDEX('Lookup High'!$C$2:$D$45,MATCH(AM2,'Lookup
High'!$C$2:$C$45,),MATCH(BM$1,'Lookup
High'!$C$2:$D$2,)))),IF($F2="YY",(INDEX('Lookup
High'!$E$2:$F$45,MATCH(AM2,'Lookup
High'!$E$2:$E$45,),MATCH(BM$1,'Lookup High'!$E$2:$F$2,)))))

=IF($F2="NN",((INDEX('Lookup STD'!$C$2:$D$45,MATCH(AM2,'Lookup
STD'!$C$2:$C$45,),MATCH(BM$1,'Lookup
STD'!$C$2:$D$2,)))),IF($F2="NY",(INDEX('Lookup
STD'!$E$2:$F$45,MATCH(AM2,'Lookup STD'!$E$2:$E$45,),MATCH(BM$1,'Lookup
STD'!$E$2:$F$2,)))))

When I combine these:

=IF($F2="YN",((INDEX('Lookup High'!$C$2:$D$45,MATCH(AM2,'Lookup
High'!$C$2:$C$45,),MATCH(BM$1,'Lookup
High'!$C$2:$D$2,)))),IF($F2="YY",(INDEX('Lookup
High'!$E$2:$F$45,MATCH(AM2,'Lookup
High'!$E$2:$E$45,),MATCH(BM$1,'Lookup
High'!$E$2:$F$2,))))),IF($F2="NN",((INDEX('Lookup
STD'!$C$2:$D$45,MATCH(AM2,'Lookup STD'!$C$2:$C$45,),MATCH(BM$1,'Lookup
STD'!$C$2:$D$2,)))),IF($F2="NY",(INDEX('Lookup
STD'!$E$2:$F$45,MATCH(AM2,'Lookup STD'!$E$2:$E$45,),MATCH(BM$1,'Lookup
STD'!$E$2:$F$2,)))))

Excel gives the result #VALUE!

Any help in spotting the error would be appreciated.

I would also like to return the value 0 if none of the conditions are
met.

Thanks in advance
Tlosgyl3



--
tlosgyl3
------------------------------------------------------------------------
tlosgyl3's Profile:
http://www.excelforum.com/member.php...o&userid=28074
View this thread: http://www.excelforum.com/showthread...hreadid=559277



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default If Function with Multiple Conditions


Thanks I'll give that a try - its a new appraoch to me.
Other ideas welcome

tlosgyl3


--
tlosgyl3
------------------------------------------------------------------------
tlosgyl3's Profile: http://www.excelforum.com/member.php...o&userid=28074
View this thread: http://www.excelforum.com/showthread...hreadid=559277

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default If Function with Multiple Conditions

I took the idea that Don Guillett offered up and ran it out a little further.
Here is the 'general' logic formula that I came up with:

=IF(LEFT($F$2,1)="Y",IF(RIGHT($F$2,1)="Y","YY",IF( RIGHT($F$2,1)<"N","Y?","YN")),IF(LEFT($F$2,1)<"N ","??",IF(RIGHT($F$2,1)="Y","NY",IF(RIGHT($F$2,1)< "N","N?","NN"))))

Anywhere there is a question mark in a potential output value, that's where
you would want a zero. The outher output indications are where you'd
substitute the appropriate INDEX() formula.

Before going on, a couple of comments about the MATCH() statements inside of
the INDEX() functions - I notice that in the 2nd MATCH() you use absolute row
reference to BM$1, but in the first one you don't for AM2. Was that
intentional? Also, in the matches, you've left the type of match empty, you
could remove that last comma with the same result: default match type of 1
assumed. Saves you some characters in the formula entries.

Now, by substituting the INDEX() formulas where there are logic result
indicators like "YY" earlier, I end up with:
=IF(LEFT($F$2,1)="Y",IF(RIGHT($F$2,1)="Y",INDEX(Lo okupHigh!$E$2:$F$45,MATCH(AM2,LookupHigh!$E$2:$E$4 5,),MATCH(BM$1,LookupHigh!$E$2:$F$2,))),IF(RIGHT($ F$2,1)<"N",0,INDEX(LookupHigh!$C$2:$D$45,MATCH(AM 2,LookupHigh!$C$2:$C$45,),MATCH(BM$1,LookupHigh!$C $2:$D$2,)))),IF(LEFT($F$2,1)<"N",0,IF(RIGHT($F$2, 1)="Y",INDEX(LookupSTD!$E$2:$F$45,MATCH(AM2,Lookup STD!$E$2:$E$45,),MATCH(BM$1,LookupSTD!$E$2:$F$2,)) ,IF(RIGHT($F$2,1)<"N",0,INDEX(LookupSTD!$C$2:$D$4 5,MATCH(AM2,LookupSTD!$C$2:$C$45,),MATCH(BM$1,Look upSTD!$C$2:$D$2,)))))

I hope these ideas help some.



Since I don't have your LookupSTD or LookupHigh sheets and data available
it's a little difficult to test and I'm kind of rushed to come up with some
test data to check it out with.



"tlosgyl3" wrote:


Using Lookup I want to return a value to a cell based upon 2 conditions,
which can exist in any one of four combinations:
YY
YN
NY
YN

The first letter determines which of two Lookup tables are used (Lookup
High or Lookup Std) the second determines which column in the relevant
Lookup table to use for the value to be returned.

I have the two following expressions each of which returns a correct
value but only if the first letter condition is correct (Y or N).

=IF($F2="YN",((INDEX('Lookup High'!$C$2:$D$45,MATCH(AM2,'Lookup
High'!$C$2:$C$45,),MATCH(BM$1,'Lookup
High'!$C$2:$D$2,)))),IF($F2="YY",(INDEX('Lookup
High'!$E$2:$F$45,MATCH(AM2,'Lookup
High'!$E$2:$E$45,),MATCH(BM$1,'Lookup High'!$E$2:$F$2,)))))

=IF($F2="NN",((INDEX('Lookup STD'!$C$2:$D$45,MATCH(AM2,'Lookup
STD'!$C$2:$C$45,),MATCH(BM$1,'Lookup
STD'!$C$2:$D$2,)))),IF($F2="NY",(INDEX('Lookup
STD'!$E$2:$F$45,MATCH(AM2,'Lookup STD'!$E$2:$E$45,),MATCH(BM$1,'Lookup
STD'!$E$2:$F$2,)))))

When I combine these:

=IF($F2="YN",((INDEX('Lookup High'!$C$2:$D$45,MATCH(AM2,'Lookup
High'!$C$2:$C$45,),MATCH(BM$1,'Lookup
High'!$C$2:$D$2,)))),IF($F2="YY",(INDEX('Lookup
High'!$E$2:$F$45,MATCH(AM2,'Lookup
High'!$E$2:$E$45,),MATCH(BM$1,'Lookup
High'!$E$2:$F$2,))))),IF($F2="NN",((INDEX('Lookup
STD'!$C$2:$D$45,MATCH(AM2,'Lookup STD'!$C$2:$C$45,),MATCH(BM$1,'Lookup
STD'!$C$2:$D$2,)))),IF($F2="NY",(INDEX('Lookup
STD'!$E$2:$F$45,MATCH(AM2,'Lookup STD'!$E$2:$E$45,),MATCH(BM$1,'Lookup
STD'!$E$2:$F$2,)))))

Excel gives the result #VALUE!

Any help in spotting the error would be appreciated.

I would also like to return the value 0 if none of the conditions are
met.

Thanks in advance
Tlosgyl3



--
tlosgyl3
------------------------------------------------------------------------
tlosgyl3's Profile: http://www.excelforum.com/member.php...o&userid=28074
View this thread: http://www.excelforum.com/showthread...hreadid=559277


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default If Function with Multiple Conditions


Please excuse delay in replying. Thanks for your contribution - I'll get
on with trying it out.

The Match references are correct but the $ could now be dropped it is a
legacy of my wanting to drag the expression down through a column.

My tables are a bit chunky to post here. Let me give your solution a
try and get back to you.

Thanks

Tlosgyl3


--
tlosgyl3
------------------------------------------------------------------------
tlosgyl3's Profile: http://www.excelforum.com/member.php...o&userid=28074
View this thread: http://www.excelforum.com/showthread...hreadid=559277



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default If Function with Multiple Conditions


Gentelmen - my apologies. Your are corresponding with a man who can't
count brackets. Once corected to
=IF(AM2<0,(IF($F2="YN",((INDEX(High!$C$2:$D$45,MA TCH(AM2,High!$C$2:$C$45,),MATCH(BM$1,High!$C$2:$D$ 2,)))),IF($F2="YY",((INDEX(High!$E$2:$F$45,MATCH(A M2,High!$E$2:$E$45,),MATCH(BM$1,High!$E$2:$F$2,))) ),IF($F2="NN",((INDEX(Std!$C$2:$D$45,MATCH(AM2,Std !$C$2:$C$45,),MATCH(BM$1,Std!$C$2:$D$2,)))),IF($F2 ="NY",((INDEX(Std!$E$2:$F$45,MATCH(AM2,Std!$E$2:$E $45,),MATCH(BM$1,Std!$E$2:$F$2,))))))))),0)

It computes correctly

tlosgyl3http://www.excelforum.com/images/smilies/eek.gif



--
tlosgyl3
------------------------------------------------------------------------
tlosgyl3's Profile: http://www.excelforum.com/member.php...o&userid=28074
View this thread: http://www.excelforum.com/showthread...hreadid=559277

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default If Function with Multiple Conditions

Don't feel bad, figuring out how many closing parenthesis and where they need
to be is a continuing problem around my house also. Glad you got it working.
Usually better to have something working that you understand than to have
something working that, should it break, you'd have a dickens of a time
repairing. That's one reason I sometimes stick with the "old ways" rather
than jumping on some suggested esoteric code in a MSFT KnowledgeBase article.

"tlosgyl3" wrote:


Gentelmen - my apologies. Your are corresponding with a man who can't
count brackets. Once corected to
=IF(AM2<0,(IF($F2="YN",((INDEX(High!$C$2:$D$45,MA TCH(AM2,High!$C$2:$C$45,),MATCH(BM$1,High!$C$2:$D$ 2,)))),IF($F2="YY",((INDEX(High!$E$2:$F$45,MATCH(A M2,High!$E$2:$E$45,),MATCH(BM$1,High!$E$2:$F$2,))) ),IF($F2="NN",((INDEX(Std!$C$2:$D$45,MATCH(AM2,Std !$C$2:$C$45,),MATCH(BM$1,Std!$C$2:$D$2,)))),IF($F2 ="NY",((INDEX(Std!$E$2:$F$45,MATCH(AM2,Std!$E$2:$E $45,),MATCH(BM$1,Std!$E$2:$F$2,))))))))),0)

It computes correctly

tlosgyl3http://www.excelforum.com/images/smilies/eek.gif



--
tlosgyl3
------------------------------------------------------------------------
tlosgyl3's Profile: http://www.excelforum.com/member.php...o&userid=28074
View this thread: http://www.excelforum.com/showthread...hreadid=559277


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use IF function for two conditions wuwu Excel Worksheet Functions 3 April 29th 23 11:42 AM
Logiacl function with multiple conditions stellarblue11 Excel Worksheet Functions 4 May 25th 06 03:55 PM
COUNTIF - multiple conditions allphin Excel Worksheet Functions 4 September 18th 05 04:05 PM
Excel option to store trendline's coefficients in cells for use Miguel Saldana Charts and Charting in Excel 9 June 20th 05 08:45 PM
Vlookup with multiple conditions cambrus Excel Worksheet Functions 1 March 11th 05 05:21 PM


All times are GMT +1. The time now is 09:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"