check for combinations in Excel?

2019-02-21 06:53发布

问题:

I have two multiple choice questions with 9 possible choices, which makes up for 20 combinations of answers. Each combination is assigned a value. In excel, I need to check answers for different combinations and tell me the value for that combination.

How is this possible? What formula do I need to use?

Example Q&A

Possible Answers

Here's what I've tried it works but i need to make 20 such IF statements. Is there a better way?

=IF(B2 ="Squeaky clean",IF(C2="Just once","Normal"),IF(B2="A little tingly. Sometimes it stings",IF(C2="Just once","Sensitive")))

回答1:

Alright, so question 1 has 4 possible answers, Question 2 has 5 possible answer. Each answer has a possible response which may or may not be unique.

I took the approach as treating each result to be unique. There is nothing stopping you from repeating results though.

Build your self a table of Questions and Results. Then where you want the results to appear, use the following formula and adjust the cell references to match your Q&A table.

=INDEX($F$2:$F$21,SUMPRODUCT((A2=$D$2:$D$21)*(B2=$E$2:$E$21)*ROW($D$2:$D$21))-ROWS(1:1))

The sumproduct returns the row number where bother your Question 1 and Question 2 answers are found.

The -ROW(1:1) subtracts your header row count. if you have two header rows about your Q&A Table you could use either -2 or -ROW(1:2).

Index looks through the results column of your Q&A table and returns the result corresponding to the row number from the sumproduct - headers rows

Now all if you follow the example and substitute you sentences for the letters, and put your results in columns F you should have something that works for you. Remember there is nothing stopping you from having the same result multiple times. On a small data table this is not so bad. IF you have the same result repeated multiple times on a large data table we could then look at a different approach.