Generating a list from a dyamic array

Patrick020

New Member
Joined
Mar 20, 2018
Messages
15
Hi everyone <o:p></o:p>
<o:p> </o:p>
I would like to generate a list which calculates the largestshortfalls out of a variety of projects. Shortfall is defined as Revenue minusCost. <o:p></o:p>
<o:p> </o:p>
I would like the formulas to allow you to select a specificfunction from which to assess their projects (in cell G1 below). The array thereforeneeds to dynamic and change depending on which function you choose in G1 whichis what I am struggling with. <o:p></o:p>
<o:p> </o:p>
I have put an example below: <o:p></o:p>
<o:p> </o:p>
Ideally I would like a formula to drag down in F4 and in G4.<o:p></o:p>
<o:p> </o:p>
A<o:p></o:p>
B<o:p></o:p>
C<o:p></o:p>
D<o:p></o:p>
E<o:p></o:p>
F<o:p></o:p>
G<o:p></o:p>
1<o:p></o:p>
Function<o:p></o:p>
Project<o:p></o:p>
Cost<o:p></o:p>
Revenue <o:p></o:p>
Selection: <o:p></o:p>
Ops <o:p></o:p>
2<o:p></o:p>
Sales <o:p></o:p>
Project 1<o:p></o:p>
50<o:p></o:p>
41<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
3<o:p></o:p>
Sales <o:p></o:p>
Project 2<o:p></o:p>
21<o:p></o:p>
5<o:p></o:p>
Deficit <o:p></o:p>
Project<o:p></o:p>
4<o:p></o:p>
Sales <o:p></o:p>
Project 3<o:p></o:p>
6<o:p></o:p>
44<o:p></o:p>
-14<o:p></o:p>
Option 2 <o:p></o:p>
5<o:p></o:p>
Sales <o:p></o:p>
Project 4<o:p></o:p>
66<o:p></o:p>
19<o:p></o:p>
-14<o:p></o:p>
Option 3<o:p></o:p>
6<o:p></o:p>
Sales <o:p></o:p>
Project 5<o:p></o:p>
36<o:p></o:p>
25<o:p></o:p>
-4<o:p></o:p>
Option 1<o:p></o:p>
7<o:p></o:p>
HR <o:p></o:p>
Scheme 1<o:p></o:p>
80<o:p></o:p>
66<o:p></o:p>
9<o:p></o:p>
Option 4 <o:p></o:p>
8<o:p></o:p>
HR <o:p></o:p>
Scheme 2<o:p></o:p>
69<o:p></o:p>
17<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
9<o:p></o:p>
HR <o:p></o:p>
Scheme 3<o:p></o:p>
27<o:p></o:p>
57<o:p></o:p>
10<o:p></o:p>
Ops<o:p></o:p>
Option 1<o:p></o:p>
77<o:p></o:p>
73<o:p></o:p>
11<o:p></o:p>
Ops<o:p></o:p>
Option 2<o:p></o:p>
68<o:p></o:p>
54<o:p></o:p>
12<o:p></o:p>
Ops<o:p></o:p>
Option 3<o:p></o:p>
19<o:p></o:p>
5<o:p></o:p>
13<o:p></o:p>
Ops<o:p></o:p>
Option 4<o:p></o:p>
54<o:p></o:p>
63<o:p></o:p>
14<o:p></o:p>
Ops<o:p></o:p>
Option 5<o:p></o:p>
39<o:p></o:p>
72<o:p></o:p>
15<o:p></o:p>
Ops<o:p></o:p>
Option 6<o:p></o:p>
39<o:p></o:p>
53<o:p></o:p>
<tbody> </tbody>
<o:p> </o:p>
Hopefully that’s clear but let me know if not! <o:p></o:p>
<o:p> </o:p>
Thank you<o:p></o:p>
Patrick
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Book1
ABCDEFGH
1FunctionProjectCostRevenueSelection:Ops
2SalesProject 15041
3SalesProject 2215DeficitProject
4SalesProject 364414Option 6
5SalesProject 4661933Option 5
6SalesProject 536259Option 4
7HRScheme 18066-14Option 3
8HRScheme 26917-14Option 2
9HRScheme 32757-4Option 1
10OpsOption 17773
11OpsOption 26854
12OpsOption 3195
13OpsOption 45463
14OpsOption 53972
15OpsOption 63953
16
Sheet


Formula in cell G4:
=LOOKUP(2, 1/((COUNTIF($G$3:G3, $B$2:$B$15)=0)*($G$1=$A$2:$A$15)), $B$2:$B$15)

Formula in cell F4:
=SUMIFS($D$2:$D$15,$A$2:$A$15,$G$1,$B$2:$B$15,G4)-SUMIFS($C$2:$C$15,$A$2:$A$15,$G$1,$B$2:$B$15,G4)

Drag to cells below.
 
Upvote 0
Hi Oscar

Apologies I probably should have made it clearer that the list in F4:F7 needs to identify the largest shortfalls first (i.e. this is the ranking aspect). To provide some context on this request - the actual spreadsheet has approx. 100 projects for some functions, so I only want to pull the top ten shortfalls.

The table I have in the OP lists the correct answer for Ops - it should list Option 2 and Option 3 first as they are the largest shortfalls at -14.

I have added another example below this time with Sales to make it clear:

A<o:p></o:p>
B<o:p></o:p>
C<o:p></o:p>
D<o:p></o:p>
E<o:p></o:p>
F<o:p></o:p>
G<o:p></o:p>
1<o:p></o:p>
Function<o:p></o:p>
Project<o:p></o:p>
Cost<o:p></o:p>
Revenue <o:p></o:p>
Selection: <o:p></o:p>
Sales<o:p></o:p>
2<o:p></o:p>
Sales <o:p></o:p>
Project 1<o:p></o:p>
50<o:p></o:p>
41<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
3<o:p></o:p>
Sales <o:p></o:p>
Project 2<o:p></o:p>
21<o:p></o:p>
5<o:p></o:p>
Deficit <o:p></o:p>
Project<o:p></o:p>
4<o:p></o:p>
Sales <o:p></o:p>
Project 3<o:p></o:p>
6<o:p></o:p>
44<o:p></o:p>
-47<o:p></o:p>
Project 4 <o:p></o:p>
5<o:p></o:p>
Sales <o:p></o:p>
Project 4<o:p></o:p>
66<o:p></o:p>
19<o:p></o:p>
-16<o:p></o:p>
Project 2<o:p></o:p>
6<o:p></o:p>
Sales <o:p></o:p>
Project 5<o:p></o:p>
36<o:p></o:p>
25<o:p></o:p>
-11<o:p></o:p>
Project 5<o:p></o:p>
7<o:p></o:p>
HR <o:p></o:p>
Scheme 1<o:p></o:p>
80<o:p></o:p>
66<o:p></o:p>
-9<o:p></o:p>
Project 1 <o:p></o:p>
8<o:p></o:p>
HR <o:p></o:p>
Scheme 2<o:p></o:p>
69<o:p></o:p>
17<o:p></o:p>
38<o:p></o:p>
Project 3 <o:p></o:p>
9<o:p></o:p>
HR <o:p></o:p>
Scheme 3<o:p></o:p>
27<o:p></o:p>
57<o:p></o:p>
10<o:p></o:p>
Ops<o:p></o:p>
Option 1<o:p></o:p>
77<o:p></o:p>
73<o:p></o:p>
11<o:p></o:p>
Ops<o:p></o:p>
Option 2<o:p></o:p>
68<o:p></o:p>
54<o:p></o:p>
12<o:p></o:p>
Ops<o:p></o:p>
Option 3<o:p></o:p>
19<o:p></o:p>
5<o:p></o:p>
13<o:p></o:p>
Ops<o:p></o:p>
Option 4<o:p></o:p>
54<o:p></o:p>
63<o:p></o:p>
14<o:p></o:p>
Ops<o:p></o:p>
Option 5<o:p></o:p>
39<o:p></o:p>
72<o:p></o:p>
15<o:p></o:p>
Ops<o:p></o:p>
Option 6<o:p></o:p>
39<o:p></o:p>
53<o:p></o:p>

<tbody>
</tbody>
 
Upvote 0
To make this easier we can ignore the deficit aspect – it’s the dynamic array part that I am really concerned about. <o:p></o:p>
<o:p></o:p>
I have therefore simplified the example below: <o:p></o:p>
<o:p></o:p>
The simplified objective is to create a list which calculates the largest values based on the selection in G2. A formula is required in in F4 (to identify the values) and in G4 (to identify the project name). <o:p></o:p>
<o:p></o:p>
A<o:p></o:p>
B<o:p></o:p>
C<o:p></o:p>
D<o:p></o:p>
E<o:p></o:p>
F<o:p></o:p>
G<o:p></o:p>
1<o:p></o:p>
Function<o:p></o:p>
Project<o:p></o:p>
Value<o:p></o:p>
<o:p></o:p>
Selection: <o:p></o:p>
Sales<o:p></o:p>
2<o:p></o:p>
Sales <o:p></o:p>
Project 1<o:p></o:p>
50<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
3<o:p></o:p>
Sales <o:p></o:p>
Project 2<o:p></o:p>
21<o:p></o:p>
<o:p></o:p>
Value <o:p></o:p>
Project<o:p></o:p>
4<o:p></o:p>
Sales <o:p></o:p>
Project 3<o:p></o:p>
6<o:p></o:p>
<o:p></o:p>
66<o:p></o:p>
Project 4 <o:p></o:p>
5<o:p></o:p>
Sales <o:p></o:p>
Project 4<o:p></o:p>
66<o:p></o:p>
<o:p></o:p>
50<o:p></o:p>
Project 1<o:p></o:p>
6<o:p></o:p>
Sales <o:p></o:p>
Project 5<o:p></o:p>
36<o:p></o:p>
<o:p></o:p>
36<o:p></o:p>
Project 5<o:p></o:p>
7<o:p></o:p>
HR <o:p></o:p>
Scheme 1<o:p></o:p>
80<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
8<o:p></o:p>
HR <o:p></o:p>
Scheme 2<o:p></o:p>
69<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
9<o:p></o:p>
HR <o:p></o:p>
Scheme 3<o:p></o:p>
27<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
10<o:p></o:p>
Ops<o:p></o:p>
Option 1<o:p></o:p>
77<o:p></o:p>
<o:p></o:p>
11<o:p></o:p>
Ops<o:p></o:p>
Option 2<o:p></o:p>
68<o:p></o:p>
<o:p></o:p>
12<o:p></o:p>
Ops<o:p></o:p>
Option 3<o:p></o:p>
19<o:p></o:p>
<o:p></o:p>
13<o:p></o:p>
Ops<o:p></o:p>
Option 4<o:p></o:p>
54<o:p></o:p>
<o:p></o:p>
14<o:p></o:p>
Ops<o:p></o:p>
Option 5<o:p></o:p>
39<o:p></o:p>
<o:p></o:p>
15<o:p></o:p>
Ops<o:p></o:p>
Option 6<o:p></o:p>
39<o:p></o:p>
<o:p></o:p>

<tbody>
</tbody>
 
Last edited:
Upvote 0
Array formula in cell F4:
=LARGE(($A$2:$A$15=$G$1)*$C$2:$C$15,ROWS($A$1:A1))

Array formula in cell G4:
=INDEX($B$2:$B$15,MIN(IF(($A$2:$A$15=$G$1)*($C$2:$C$15=F4)*(COUNTIF($G$3:G3,$B$2:$B$15)=0),MATCH(ROW($A$2:$A$15),ROW($A$2:$A$15)),"")))
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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