Calculation Winner by fulfilling multiple conditions

arifgold

New Member
Joined
Feb 6, 2018
Messages
7
Hi, I want to calculate the winner by fulfilling these following conditions. For example I gave a Winner list at the bottom of this page.

Conditions:
1. The Winner will be he, who achieved maximum Sales

2. Department "A" winners cannot exit 6
3. Department "B" winners cannot be more than 3
4. Department "c" winners cannot be more than 1
5. Group "X" winners cannot exit 6
6. Group "Y" winners cannot exit 3
7. Group "Z" winners cannot exit 1

----------------------
Data:

GroupDepartmentSales (amount)
zB14500
xA13500
yB13000
xA8567
xA5000
yA5000
yA4750
xA4000
xA3750
zC3309
zA2000
zC1905
xC1500
xA950
xB900
xB850
xA850
yC800
yA750
zA700
zB700
zA600
yA500
yA500
yA400
yB350
xA300
zA290
xA275
xC250
xB250
xB150
zB100

<tbody>
</tbody>

-------------------------------------

Example based on above Data:
RANKGroupDepartmentSalesResult
1ZB 14,500Winner
2XA 13,500Winner
3yB 13,000Winner
4XA 8,567Winner
5YA 5,000Winner
6YA 4,750Winner
7XA 3,750Winner
8XC 1,500Winner
9XA 950Winner
10XB 900Winner

<tbody>
</tbody>

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Welcome to the Board!

I think you mean "exceed" instead of "exit". If so, I came up with this solution:

ABCDEFGHIJKL
1GroupDepartmentSales (amount)DepartmentMax winnersGroupMax winnersWinners
2zB14500A6x6GroupDepartmentAmount
3xA13500B3y3zB14500
4yB13000C1z1xA13500
5xA8567yB13000
6xA5000xA8567
7yA5000xA5000
8yA4750yA5000
9xA4000yA4750
10xA3750xA4000
11zC3309xC1500
12zA2000xB900
13zC19050
14xC15000
15xA9500
16xB9000
17xB8500
18xA8500
19yC8000
20yA7500
21zA7000
22zB700
23zA600
24yA500
25yA500
26yA400
27yB350
28xA300
29zA290
30xA275
31xC250
32xB250
33xB150
34zB100

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet8

Array Formulas
CellFormula
J3{=IFERROR(INDEX($A$2:$A$34,SMALL(IF($C$2:$C$34=$L3,IF(COUNTIF($K$2:$K2,$B$2:$B$34)<SUMIF($E$2:$E$4,$B$2:$B$34,$F$2:$F$4),IF(COUNTIF($J$2:$J2,$A$2:$A$34)<SUMIF($G$2:$G$4,$A$2:$A$34,H$2:$H$4),ROW($A$2:$A$34)-ROW($A$2)+1))),COUNTIF($L$3:$L3,$L3))),"")}
K3{=IFERROR(INDEX($B$2:$B$34,SMALL(IF($C$2:$C$34=$L3,IF(COUNTIF($K$2:$K2,$B$2:$B$34)<SUMIF($E$2:$E$4,$B$2:$B$34,$F$2:$F$4),IF(COUNTIF($J$2:$J2,$A$2:$A$34)<SUMIF($G$2:$G$4,$A$2:$A$34,H$2:$H$4),ROW($A$2:$A$34)-ROW($A$2)+1))),COUNTIF($L$3:$L3,$L3))),"")}
L3{=MAX(IF(COUNTIFS($J$2:$J2,$A$2:A$34,$K$2:$K2,$B$2:$B$34,$L$2:$L2,$C$2:$C$34)=0,IF(COUNTIF($K$2:$K2,$B$2:$B$34)<SUMIF($E$2:$E$4,$B$2:$B$34,$F$2:$F$4),IF(COUNTIF($J$2:$J2,$A$2:$A$34)<SUMIF($G$2:$G$4,$A$2:$A$34,H$2:$H$4),$C$2:$C$34))))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



My result table is a little different than your expected results, please check to see if it is correct. Also, I probably could have simplified the formulas if I'd assumed that the amounts are in sorted order, but I didn't assume that. Even so, probably easier in VBA.

Let me know if this helps.
 
Upvote 0
Welcome to the Board!

I think you mean "exceed" instead of "exit". If so, I came up with this solution:

ABCDEFGHIJKL
1GroupDepartmentSales (amount)DepartmentMax winnersGroupMax winnersWinners
2zB14500A6x6GroupDepartmentAmount
3xA13500B3y3zB14500
4yB13000C1z1xA13500
5xA8567yB13000
6xA5000xA8567
7yA5000xA5000
8yA4750yA5000
9xA4000yA4750
10xA3750xA4000
11zC3309xC1500
12zA2000xB900
13zC19050
14xC15000
15xA9500
16xB9000
17xB8500
18xA8500
19yC8000
20yA7500
21zA7000
22zB700
23zA600
24yA500
25yA500
26yA400
27yB350
28xA300
29zA290
30xA275
31xC250
32xB250
33xB150
34zB100

<tbody>
</tbody>
Sheet8

Array Formulas
CellFormula
J3{=IFERROR(<font color="Blue">INDEX(<font color="Red">$A$2:$A$34,SMALL(<font color="Green">IF(<font color="Purple">$C$2:$C$34=$L3,IF(COUNTIF($K$2:$K2,$B$2:$B$34)<sumif($E$2:$E$4,$B$2:$B$34,$F$2:$F$4</sumif(),IF(COUNTIF($J$2:$J2,$A$2:$A$34)<sumif($G$2:$G$4,$A$2:$A$34,H$2:$H$4</sumif(),ROW($A$2:$A$34)-ROW($A$2)+1))),COUNTIF($L$3:$L3,$L3))),"")}
K3{=IFERROR(<font color="Blue">INDEX(<font color="Red">$B$2:$B$34,SMALL(<font color="Green">IF(<font color="Purple">$C$2:$C$34=$L3,IF(COUNTIF($K$2:$K2,$B$2:$B$34)<sumif($E$2:$E$4,$B$2:$B$34,$F$2:$F$4</sumif(),IF(COUNTIF($J$2:$J2,$A$2:$A$34)<sumif($G$2:$G$4,$A$2:$A$34,H$2:$H$4</sumif(),ROW($A$2:$A$34)-ROW($A$2)+1))),COUNTIF($L$3:$L3,$L3))),"")}
L3{=MAX(<font color="Blue">IF(<font color="Red">COUNTIFS($J$2:$J2,$A$2:A$34,$K$2:$K2,$B$2:$B$34,$L$2:$L2,$C$2:$C$34)=0,IF(<font color="Green">COUNTIF($K$2:$K2,$B$2:$B$34)<sumif(<font color="Purple">$E$2:$E$4,$B$2:$B$34,$F$2:$F$4</sumif(),IF(COUNTIF($J$2:$J2,$A$2:$A$34)<sumif($G$2:$G$4,$A$2:$A$34,H$2:$H$4</sumif(),$C$2:$C$34))))}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



My result table is a little different than your expected results, please check to see if it is correct. Also, I probably could have simplified the formulas if I'd assumed that the amounts are in sorted order, but I didn't assume that. Even so, probably easier in VBA.

Let me know if this helps.


---------------------------------------------------

Dear Eric,

Thank you for your quick reply. The formula is showing error. please help.
 
Upvote 0
Dear Eric,

Thank you for your quick reply. The formula is showing error. Can you please provide the correct formulas.
 
Upvote 0
Dear Eric,

Thank you for your quick reply. The formula is showing error. Can you please provide the correct formulas. and Yes, I need the result in order largest to smallest.
 
Upvote 0
If acceptable I would create a Helper column to use simpler formulas.

Something like this

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
1
Group​
Department​
Sales​
Dept/Group​
Max winners​
Rank​
Group​
Department​
Sales (amount)​
Result​
Helper​
Count​
2
z​
B​
14500​
A​
6​
1​
z​
B​
14500​
Winner​
Winner1​
10​
3
x​
A​
13500​
B​
3​
2​
x​
A​
13500​
Winner​
Winner2​
4
y​
B​
13000​
C​
1​
3​
y​
B​
13000​
Winner​
Winner3​
5
x​
A​
8567​
x​
6​
4​
x​
A​
8567​
Winner​
Winner4​
6
x​
A​
5000​
y​
3​
5​
x​
A​
5000​
Winner​
Winner5​
7
y​
A​
5000​
z​
1​
6​
y​
A​
5000​
Winner​
Winner6​
8
y​
A​
4750​
7​
y​
A​
4750​
Winner​
Winner7​
9
x​
A​
4000​
8​
x​
A​
4000​
Winner​
Winner8​
10
x​
A​
3750​
9​
x​
C​
1500​
Winner​
11
z​
C​
3309​
10​
x​
B​
900​
Winner​
12
z​
A​
2000​
13
z​
C​
1905​
14
x​
C​
1500​
Winner9​
15
x​
A​
950​
16
x​
B​
900​
Winner10​
17
x​
B​
850​
18
x​
A​
850​
19
y​
C​
800​
20
y​
A​
750​
21
z​
A​
700​
22
z​
B​
700​
23
z​
A​
600​
24
y​
A​
500​
25
y​
A​
500​
26
y​
A​
400​
27
y​
B​
350​
28
x​
A​
300​
29
z​
A​
290​
30
x​
A​
275​
31
x​
C​
250​
32
x​
B​
250​
33
x​
B​
150​
34
z​
B​
100​
35

<tbody>
</tbody>

Helper column (gray area)
Formula in N2 copied down
=IF(A2="","",IF(OR(COUNTIFS(A$1:A1,A2,N$1:N1,"Winner*")=VLOOKUP(A2,E$2:F$7,2,0),COUNTIFS(B$1:B1,B2,N$1:N1,"Winner*")=VLOOKUP(B2,E$2:F$7,2,0)),"","Winner"&COUNTIF(N$1:N1,"?*")))

Formula in O2 to count the winners
=COUNTIFS(N:N,"Winner*")

Formula in H2 copied down
=IF(O$2>=ROWS(I$2:I2),ROWS(I$2:I2),"")

Formula in I2 copied across till K2 and down
=IF($H2="","",INDEX(A:A,MATCH("Winner"&$H2,$N:$N,0)))

Formula in L2 copied down
=IF(H2="","","Winner")

Hope this helps

M.
 
Upvote 0
Dear Marcelo ,

WOW!!! you are a Genius. Thanks a lot. I will back to you if I need further help on this.

Thank you so much.

Best regards,

Arif
 
Upvote 0
You are welcome. Glad to help :)

M.

Dear Marcelo,

Good day!

1. If we change the "Sales" amount the formula is not showing the correct result.

2. After input all the sales amount and before calculation the Winner, we need a table to sort the Sales amount largest to smallest order.

Please Help!

Regards,
 
Upvote 0
Yes, the formula works only if the Sales are sorted accordingly.
You can do this by selecting the data and going to Data, Sort by Sales column, largest to smallest.

M.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,727
Messages
6,126,521
Members
449,316
Latest member
sravya

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