简体   繁体   中英

Excel - ASSIGNING PRIORITY

Logically, I have a hierarchal set of strings that looks like this:

Priority 1 = "SAME" <---Most important

Priority 2 = "DIFFERENT"

Priority 3 = "CLASSICAL"

Priority 4 = "DROPPED" <---Least important

If I have 5 contiguous Excel cells, with any combination of 1 of the above strings in each cell, I would like to have the sixth cell displaying the highest priority if it exists AT LEAST ONCE. Many combinations can occur, below are a few examples of what I'm trying to achieve with each example depicting 5 contiguous cells with a string in each:

Example 1:

| DROPPED | DROPPED | CLASSICAL | DROPPED | DROPPED |

Sixth cell should equal: | CLASSICAL | | CLASSICAL | because it is of highest priority which shows up at least once

Example 2:

| CLASSICAL | DIFFERENT| SAME | DROPPED | DIFFERENT|

Sixth cell should equal: | SAME | | SAME | because it is of highest priority which shows up at least once

Example 3:

| DIFFERENT | CLASSICAL |CLASSICAL | DROPPED | DIFFERENT |

Sixth cell should equal: | DIFFERENT | | DIFFERENT | because it is of highest priority which shows up at least once

If you added the number in front of the string like "1 SAME", "2 DIFFERENT" etc , you can use the following array formula

 =INDEX(A1:E5,MATCH(MIN(VALUE(LEFT(A1:E5,1))),VALUE(LEFT(A1:E5,1)),0))

Press CTRL + SHIFT + ENTER to enter the array formula.

Assuming your 5 contiguous cells are in columns A through E you can use this formula in cell F:

=IF(OR(A1="SAME",B1="SAME",C1="SAME",D1="SAME",E1="SAME"),"SAME",IF(OR(A1="DIFFERENT",B1="DIFFERENT",C1="DIFFERENT",D1="DIFFERENT",E1="DIFFERENT"),"DIFFERENT",IF(OR(A1="CLASSICAL",B1="CLASSICAL",C1="CLASSICAL",D1="CLASSICAL",E1="CLASSICAL"),"CLASSICAL",IF(OR(A1="DROPPED",B1="DROPPED",C1="DROPPED",D1="DROPPED",E1="DROPPED"),"DROPPED","No Match"))))

The end of the formula defines what to say if there is no match. I set it to "No Match" but you can replace that with "" for blank or whatever string you want to see. You can copy it down as many rows as needed:

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM