Choosing top scoring row (with complex logic/rules)

z3115

Board Regular
Joined
Nov 1, 2013
Messages
71
I have a set of data with different groups ("colors"). For each group (color), there are questions that apply to "categories" ("A", "B", "C", etc.). Each has a numerical score. I need to pick the highest scoring question for each category, for each group (color).



Example: Group "Blue" has 2 questions that apply to category "A". One has a score of 4, the other has a score of 2. The question with a score of 4 is the one that should be used.



This is simple enough, but there is an additional rule that makes everything more complicated: Some questions apply to multiple categories, but these questions can only be used for 1 category (or not used at all).



Because of this rule, there are several scenarios that come up, and as a result certain logic that needs to be applied:




  1. If a question applies to multiple categories and one of those categories has no other questions that apply to it, the question should be used for that category [Ex: if question 1 applies to categories A & B, and there are no other questions that apply to category A, question 1 should apply to category A. If neither category A nor category B have any other questions that apply to it, question 1 can be applied to either (but not both). It doesn't matter which one it's applied to.]
  2. If a question applies to multiple categories and each of those categories have other questions that apply to that category, the question that applies to multiple categories should be applied to lowest scoring category [Ex: "Question 4" applies to categories B & C and has a score of 7; "question 6" only applies to category B and has a score of 3. "Question 11" only applies to category C and has a score of 5. Since "question 6" scores worse than "question 11", "question 4" should be applied to category B. Note that if "question 4" had a score of 3 or lower, it would not be applied to either category


Is there any sort of formula or VBA code that can do anything like this?



Thank you all!




Example (the last column is the one I'm trying to automate):
ColorQuestionCategories it can be used forScoreCategory to apply it to
Redblah blahA4Don't Use
RedxyzA;B5A
RedgibberishC4C
RedhelloC;D5D
RedlolB6B
BlueggdfkljA4A
Blueblah blahB6B
BluexyzC4C
BluegibberishB;C3Don't Use
BluehelloD1D
GreenssasasA:B6A
GreensdsdffB4B
GreenfffrrdC4Don't Use
GreenblahD6D
GreenbrrrrC;D8C

<tbody>
</tbody>
 
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,215,026
Messages
6,122,738
Members
449,094
Latest member
dsharae57

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