excel: index match - list top 10 jobs by spend? - excel

I have a list of clients on sheet1 in a spreadsheet like so:
Date Entity Sector Client Spend
April 2016 Group1 Aerospace Client A £2,000,000.00
April 2016 Group1 Aerospace Client B £5,000,000.00
April 2016 Group2 Rail Client C £13,000.00
April 2016 Group1 Aerospace Client D £45,000.00
April 2016 Group1 Telecoms Client E £20,000.00
I want to pull through a list of the top 10 clients we spend with.
I have certain parameters / criteria i need to set, i.e.
The Client must have a 'Group1' entity and must come under the 'aerospace' sector.
In Cell A10 i place my sector = Aerosapce
In cell C6 i allocate my group = Group1
So far i am using this array formula and dragging it down 10 rows, to produce 10 unique results.
=IFERROR(INDEX('Opp Data'!$H2:$H5000,MATCH(1,('Opp Data'!$G$2:$G$5000&'Opp Data'!$F$2:$F$5000=$A$10&$C$6)*('Opp Data'!$K$2:$K$5000=LARGE(IF('Opp Data'!$G$2:$G$5000&'Opp Data'!$F$2:$F$5000=$A$10&$C$6,'Opp Data'!$K$2:$K$5000),ROW(1:1))*(COUNTIF($C$13:$C13,'Opp Data'!$H$2:$H$5000)=0)),0)),"")
This should give me the clients in order with the biggest to lowest spend, producing a result like so:
Client Sector Spend
Client B
Client A
Client D
etc
etc.
Next to the client name i want to list the relevant sector that client belongs to, i.e. "Aerospace" and the spend in the column next to that.
I am doing this by using index match:
=IFERROR(INDEX('Opp Data'!$C:$C, MATCH(A2,'Opp Data'!$D:$D, 0)),"")
At the moment the data is all over the place and spends are not corresponding with the client name, and some clients are being shown that are not in group 1 or aerospace.
I am getting this:
Client Sector Spend
Client B Rail £20,000.00
Client A Aerospace £13,000.00
Client D Telecoms £2,000,000.00
etc
etc.
But i should be getting this:
Client Sector Spend
Client B Aerospace £5,000,000.00
Client A Aerospace £2,000,000.00
Client D Aerospace £45,000.00
etc
etc.
Please can someone show me where i am going wrong and let me know if there is a better way to do this?
Thanks in advance

To get your table the best way would be a Pivot Table with filters. This will allow you to do what you want.
Outside of that IF you want the formulas then:
First get the top Spend. To do this we need to use the LARGE() or AGGREGATE() function:
=IFERROR(AGGREGATE(14,6,$E$2:$E$6/(($C$2:$C$6=$G$2)*($B$2:$B$6=$H$2)),ROW(1:1)),"")
Put this in the first cell of your Spend column and drag down. The Row(1:1) acts as a counter that increases as it gets dragged down. That way it find the first largest then the second and so forth.
The part below / dictates that only those that meet the criteria get used. I put Aerospace in G2 and Group1 in H2.
Then we can use another AGGREGATE() function in side an INDEX to get the other data on the other two columns:
Sector:
=IF(L2<>"",INDEX($C$2:$C$6,AGGREGATE(15,6,(ROW($C$2:$C$6)-1)/(($E$2:$E$6=L2)*($B$2:$B$6=$H$2)),COUNTIF($L$2:$L2,L2))),"")
Or, since we have the desired Sector already in a cell we could simply:
=IF(L2<>"",$G$2,"")
Client:
=IF(L2<>"",INDEX($D$2:$D$6,AGGREGATE(15,6,(ROW($D$2:$D$6)-1)/(($E$2:$E$6=L2)*($B$2:$B$6=$H$2)),COUNTIF($L$2:$L2,L2))),"")
We use the AGGREGATE again instead of MATCH in case there are ties with the amount in Spend. The COUNTIF() allows us to get those duplicates where Match would only return the first one for both.
When editing the ranges on the formulas to match yours pay attention to this part: (ROW($D$2:$D$6)-1) This again is a counter that returns an integer back to the INDEX() function. We need it to start at 1. So if your data starts in Row three we would need to change the 1 to 2. It should be 1 less than the starting row.
Along with Pivot Tables, look into Advanced Filter and VBA. See HERE to see how they might help with your problem.

Related

Excel formula to find a number within a range of numbers and return a date

First time writing one of these, so I will try and explain what I'm trying to do in an understandable manner.
I'm trying to create a spreadsheet to track when a premium bond wins, and have it return the date that the winning premium bond was purchased. Because premium bonds cannot be purchased singularly, when you buy them your bond numbers are given to you a range (eg: 111AA111111- 111AA111210).
As this is the data they provide, I've set my spreadsheet up with purchase date in column A, first number of the range in column B, and last number of the range in column C.
Sample image of the sheet with example bond ranges and purchase date:
Now on a separate sheet I've listed the wins, with win date in A, winning bond number in B, and prize amount in C. In D or E I would like to somehow get it to then give me from the first sheet the date of purchase that winning bond was from.
Sample image of the sheet with winning bond numbers and month they won:
I've done a lot of googling and found similar threads to do this, but none of them have been quite what I want and I've not yet been able to work out how to tweak them into doing it. These have used index and sumproduct, but I'm yet to get it to work.
Any help in the right direction is greatly appreciated. If this doesn't make sense let me know and I'll try and explain it better.
So, like this:
INDEX($B$3:$B$5,MATCH(C9,$C$3:$C$5,1))
Not added a constraint to limit to the upper value, but you could.
This answer is pretty much the same than #SolarMike's answer but based on a diferent point of view.
If the pattern is always like 111AA111111 where 1 is a numeric value and AA is a text value and unique then you can extract the text part from each id using function MID and search for it with INDEX and MATCH:
Formula is:
=INDEX($A$1:$A$3;MATCH("*"&MID(B9;4;2)&"*";$B$1:$B$3;0))
But for this to work each AA must be unique.

Efficiency question with excel using index match for each cell in a large sheet

I have a 4 types of customers, each pay in a different payment plan.
group 1 - monthly
group 2 - semi monthly
group 3 - bi weekly
group 4 - weekly
I have a sheet with a range of all the relevant payment dates for those group sorted in the right order in row 1
I would like that for each customer there will be a data validation list (group 1,group 2, group 3,group 4)
When selected the customer's row will populate on the correct dates according to his group number and the date the payment starts.
My work around to do that was to create 4 separate sheets for each group, auto populate from the correct date and run it for all customers in each group meaning you can see for John Doe what and when will be his payments in each group even though he is in group 3 for example. And a MAIN sheet where John Doe has group 3 selected where a MATCH and INDEX is running to find when he is supposed to pay and how much. The issue is that for 400 rows and 300 column this becomes heavy.
How would you go about solving that?
each cell looks like this in the MAIN sheet
=LET(mothlydate,Monthlyrd3!$BK$3:AAC$3,semidate,Monthlyth16!$BK$3:ZZ$3,namemonthly,Monthlyrd3!$BK79:AAC79,namesemi,Monthlyth16!$BK79:ZZ79,
IF(OR($BA96="Monthly 3 rd",$BA96="Semi-Monthly",$BA96="Monthly 16 th"),
IF((IF(IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")>$AE96,$AE96,IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")))=0,"",(IF(IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")>$AE96,$AE96,IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")))),
IF($BA96="Bi-Weekly 1",(IFERROR(INDEX(NewBiWeekly!$BK79:AAC79,1,MATCH(GH$2,NewBiWeekly!$BK$3:AAC$3,0)),"")),IF($BA96="Bi-Weekly 2",(IFERROR(INDEX(NewBiWeeklyTwo!$BK79:AAC79,1,MATCH(GH$2,NewBiWeeklyTwo!$BK$3:AAC$3,0)),"")),IF($BA96="Other",(IFERROR(INDEX(NewOther!$BK79:AAC79,1,MATCH(GH$2,NewOther!$BK$3:AAC$3,0)),""))))))
)
THANKS!!!
This is based on a purely textual analysis of your formula, since data required for a meaningful analysis hasn't been forthcoming:
the expression below occurs 4 times in your formula
IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")
as does this one
IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0))
which means that, in the worst-case circumstances, one or both expressions are being evaluated on FOUR separate occasions - it would be sensible to consider making one or both of these named 'values' at the start of the LET() function, such that, in the worst-case cirumstances going forward, each would be evaluated only once.

Excel - VLOOKUP with 2 conditions?

Wondering if anyone can help.
I have 2 tables. The first one has a list of which dates each vendor work against their team leader name. Displaying only:
dates they worked (A) .... vendor name (B) .... the team leader (C)
This table has got 400 lines.
The second table has a list of ALL donations each vendor did per day. Some vendors has got 5 or 6 items per day. This table is pretty similar with the first one, but because the team leader change from one day to another, one vendor may get 2 or 3 different leaders every week (but only one on a day).
This table has got 10.000 lines.
So the columns of this table are:
dates they worked (G) .... vendor name (J) .... the team leader (K)
But the K column is not populated. I need a formula that goes something like on the K column:
if (G)=(A) AND (J)=(B) return the value (C) into (K)
Can anyone help with this?
Cheer,
Bruno
You should be able to use an array version of INDEX:MATCH formula:
=INDEX(A:C,MATCH(G1&J1,A:A&B:B,0),3)
NOTE: this formula must be entered with ctrl+shift+enter

Excel - Way to calculate paying salaries

I work at a restaurant chain with about 170 employees. Currently we pay most of them by cash, and our administration team counts 'what bank notes' to pay them manually.
So for example if one of our waiters gets paid 2152 Euro, then the function should calculate the following:
100 Euro * 21
50 Euro * 1
2 Euro * 1
Anything like that in excel?
This is just one way to do it. I chose to use a helper column to keep the formulas simple for you
Here is how it looks:
This formula goes in B3 and you should drag it down. This column shows the remainder due after each note. E.g. 52€ remaining after 2100€ in 100€ notes has been accounted for)
=MOD(B2,A3)
Then place this formula in C3 and drag it down
=IF(B2<>B3,(B2-B3)/A3,0)
That will give you how many of each note to dispense to the worker.
Note
This method simply assumes you want to issue the fewest notes. It would be a good idea to have a table which allows you to indicate if you are out of a particular note so that the model uses 2x€50 notes rather than 100€ notes, for example.
Perhaps you can try to use Truncate & Divide to calculate number of notes for each given note.
for example, to get number of 100 note:
NumberOf100Note = Trunc(givenAmount/100,0)
NumberOf50Note = Trunc((givenAmount - 100 * NumberOf100Note) / 50, 0)
etc. and etc.
and you can build these very easily in excel, isn't it?

Creating a dynamic top 10 list in MS Excel 2010

I have a simple table consisting of two columns:
CLIENT REVENUE
___________________________
A 5000 USD
B 7500 USD
C 6000 USD
D 2500 USD
... ...
I want to create a dynamic top 10 client list, that automatically updates itself as revenues are changed.
I have already been able to list the top 10 revenues by using the LARGE function, but I have trouble with getting the clients' names next to the revenue numbers.
A simple way to do this would be to combine the Index and Match functions like this :
=INDEX(A:A,MATCH(E1,B:B,0))
This assumes your client names are in column A, Revenue is in column B, and the the large() revenue you are looking up is in cell E1
Additionally this simple approach will return the first client name with the 'large' revenue and in the rare event that two clients had the exact same revenue the above formula will show the first client twice.
An approach that handles the offset from duplicate revenue's would look like this:
=IF(ISNUMBER(E1),INDEX($A$1:$A$13,SMALL(IF($B$1:$B$13=E1,ROW($A$1:$A$13)-ROW($A$1)+1),COUNTIF(E$1:E1,E1))),"")
Note Array formula ctrl+shift+enter after typing, then drag down to the right of your Large() revenue numbers.
Here's a screenshot of the second formula deployed in the event that you need to use it:
(while the first approach is simple, cell F3 is an example of where the additional complexity may be required)

Resources