Hi everyone
I'm trying to divide my data into 6 different groups, based on 2 different criteria. First, I am not sure how to write the logical test to take 2 columns of data into consideration (using "&" and "AND" do not work; I am not sure what else to try), and second I can't figure out how to write the formula so that it can select from 1 of 6 conditions.
So, overall here is what I want:
If DL2=3 and CK2=1, then I want this to be labeled as '1'
If DL2=3 and CK2=2, 2
If DL2=1 and CK2=2, 3
If DL2=2 and CK2=2, 4
If DL2=1 and CK2=1, 5
If DL2=2 and CK2=1, 6
These 6 conditions cover all possible combinations of numbers in the two columns.
Any help in mashing all this into one beautiful formula would be greatly appreciated!
Last edited by binkatron5000; 10-16-2009 at 06:58 PM.
Perhaps
=MATCH(DL2+(CK2/10),{3.1,3.2,1.2,2.2,1.1,2.1},0)
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Wow, the "match" function is new to me! I am not certain how to interpret the formula but it works wonderfully![]()
Thank you so much!!!
Ok...there maybe a better way do this .. maybe sumproduct, but here is something
Nested IF with AND
I have used A's and B's instead of your DL's and CK's...easy to transpose.
=IF(AND(A1=3,B1=1),1,IF(AND(A1=3,B1=2),2,IF(AND(A1=1,B1=2),3,IF(AND(A1=2,B1=2),4,IF(AND(A1=1,B1=1),5 ,IF(AND(A1=2,B1=1),6))))))
:p see i knew there was a better way
lol
jj72uk, this is kind of how I pictured it but I just couldn't make it work. Putting the "AND" in front, derp I should have thought of that![]()
Thanks for the suggestion; If I ever need to do something similar to this again and can't work out Donkey's method then yours should be fine :D
Donkeys is cleaner and better :P learn his!!!
The match method makes use of the fact the source values are numbers, range is known and each combination can be made to be unique
DL2=3 and CK2=1 --> 3 + 1/10 -> 3.1
DL2=3 and CK2=2 --> 3 + 2/10 -> 3.2
DL2=1 and CK2=2 --> 1 + 2/10 -> 1.2
DL2=2 and CK2=2 --> 2 + 2/10 -> 2.2
DL2=1 and CK2=1 --> 1 + 1/10 -> 1.1
DL2=2 and CK2=1 --> 2 + 1/10 -> 2.1
You can then match the current value against these 6, the MATCH will return the position of the MATCH within the array of values, so
=MATCH(DL2+(CK2/10),{3.1,3.2,1.2,2.2,1.1,2.1},0)
will return the position that DL2+(CK2/10) is found... by ordering the values in the inline array correctly you will get the appropriate 1-6 return.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Thanks for explaining this, I think it makes sense![]()
Guess we'll find out if I truly get it next time I try to use it :P
Hi again,
Just to clarify: from what I understand, dividing the second number by 10 is used to make each combination total a unique number? So, theoretically you could use any number besides 10?
Edit: Hmm looking at it again maybe I am way off. It's just the /10 that I am not clear on its purpose
Last edited by binkatron5000; 10-16-2009 at 04:04 PM.
The /10 is used to ensure each combination of DL/CK is unique yes, for ex. assume
DL2 & CK2 are 1 & 2
DL3 & CK3 are 2 & 1
A simple addition of the two would generate 3 in both cases - not trying to be condescending but purely for sake of demo of logic:
1 + 2 -> 3
2 + 1 -> 3
which would cause obvious issues.
We use 10 because simply because it ensures CK when divided can never exceed 1 (given possible values of CK), eg
1 + 2/10 -> 1.2
2 + 1/10 -> 2.1
The key is to ensure the 2nd value never > 1 else you impact the first value making results void, for ex. if we used divisor of 2 rather than 10
1 + 2/2 -> 2
2 + 1/2 -> 2.5
This could lead to issues going forward ... in essence we want to be sure that neither DL & CK can be affected by one another.
Does that make sense ?
Last edited by DonkeyOte; 10-17-2009 at 01:59 AM. Reason: typo
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Yes, that makes perfect sense! I definitely understand now. You have been a great help, I can't thank you enough. Have a virtual cookie
^_^
One more way to go:
=LOOKUP(1*(D1&E1);{11;12;21;22;31;32};{5;3;6;4;1;2})
Also, please make thread [solved] as DonkeyOte provide you solution...
Last edited by zbor; 10-16-2009 at 05:02 PM.
"Relax. What is mind? No matter. What is matter? Never mind!"
Cool, thank you zbor, another good idea.
I'm sorry, how do I change the post to say resolved?
Edit: Nevermind, figured it out finally![]()
Last edited by binkatron5000; 10-29-2009 at 02:44 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks