Match Values in Excel and compute a formula - excel

Player Data
Team Data
Example Outcome
Currently I have two tables: The first, with all player data in the basketball conference (Pts, Ast, BLks, Rebs, etc) and the second, with all the team data in the conference (Pts, Ast, BLks, Rebs, etc) the difference being the team table is the totals for the complete team. In a separate table I would like to be able to compute some additional values for each player based on both his basic stats and the teams total stats. In order to do this I believe I need to match first a player to a team using a team Name column and if the player's team name matches the team name totals then use corresponding values in the rest of the columns within that team name row. Then repeat this for each player in the conference.
I have tried using the MATCH and INDEX but do not believe they are what I am looking for as once I match the team names I need to use the entire rows worth of data within a formula.
Any help/guidance would be greatly appreciated

If I were you, I wouldn't create a new table for that, just add the new data you want in new columns in the players table. That way you can do this:
If your new data's column headers have the same order as the column headers you're extracting data from of the teams table, then Calculate d and put this formula in the first cell in the first new column you added to the players table, and copy it to the rest of the table.
=INDEX(TeamsTable, MATCH(TeamsColumnInPlayersTable, TeamsColumnInTeamsTable, 0), COLUMN() + d)
Where d is the difference between the column number of the cell you're adding this formula to and the column number of the of the column you want the data extracted from in TeamsTable.
For example, if you want to add new data in columns(E, F, G, H) in the players table, and these columns are extracting data from columns (L, M, N, O) in teams table respectively, then d = Num(L) - Num(E) = 12 - 5 = 7.
However, if they're not in the same order then your formula becomes this:
=INDEX(TeamsTable, MATCH(TeamsColumnInPlayersTable, TeamsColumnInTeamsTable, 0), col)
Where col is the number of the column that has the data you want extracted from. Put this formula in the first cell of each new data column and copy downward.

Related

Filling the item name from rated and ranked cells (excel)

I'm trying to get Excel to fill a column with item names that have been ranked according to a rating.
Table one: column A - there are five items in their original order (A,B,C,D,E), column B - their associated ratings (75,100,100,125,100).
Table two: column A - updated ranking of the items (1,2,2,2,5) using RANK(),column B - ordered ratings of those items (125,100,100,100,75) using LARGE(). In column C I would like to list the corresponding item (names i.e., D,B,C,E,A).
I have provided a screenshot of the layout for further clarity.
I tried using IFS() function to match ratings in table one and table two, then show the item in the same row from table one, but this doesn't work when items have the same ratings (i.e., B, C and E are all 100).
[=IFS(I18=$D$18, $A$18, I18=$D$19, $A$19,I18=$D$20, $A$20,I18=$D$21,$A$21,I18=$D$22,$A$22)]
I also tried to print the address of the cell containing the matching rating in table one using CELL("address"), then use OFFSET()to print the corresponding item, but I also couldn't get that to work.
[=OFFSET(CELL("address",INDEX($D18:$D$22,MATCH($I18,$D18:$D$22,0))),0,-3))]
I'm quite new to using formulae in excel so hopefully, this will be an easy fix for someone!
Thank you so much!

Excel-how to convert multiple rows into a single row for each unique identifier in column A

I have a large data set(over 1 million rows) of patient names, problems/diagnoses, and the dates these diagnoses were entered(with each variable as a column header).
I would like to pull data from this source file to add to an existing file which has about 900 unique patient names with other demographics(in columns).
I am not able to use the vlookup function because most patients have multiple problems.
Are there any other functions or tricks which might be helpful?
Thanks in advance for your time and efforts.
Sample of what Data Currently looks like:
Name Diagnosis Date of Dx
A Head 11/15/12
B Leg 09/08/14
B Elbow 10/11/15
C Hand 02/23/16
A Toe 04/11/13
A Eye 05/25/15
C Ear 12/21/14
What I would like Data Set to Look like:
Name Dx#1 Date#1 Dx#2 Date#2 Dx#3 Date#3
A Head 11/15/12 Toe 04/11/13 Eye 05/25/15
B Leg 09/08/14 Elbow 10/11/15 n/a n/a
C Hand 02/23/16 Ear 12/21/14 n/a n/a
I'm not sure if you're familiar with the index and match functions, but you can use those to create the sheet. The easiest way would be to add several helper columns (in your example 3) and use the match function to get the reference row that you want.
From there you can offset the search range by previous match to find the next match. You can do this as many times as necessary depending on the number of conditions a patient has.
After that it's a simple index function to fill in the rows of the table with the desired values. You can clean up the extra cells with iferror if you want.
Assuming your data is in columns A1:C8, and your output dataset is in columns E1:K4, the following formulas will give you the desired output. The helper columns are found in L1:N4. These formulas would go in row 2, but you can drag them down to calculate for the rest of the rows.
I'll add the column above each formula:
E
No formula, list all patient names
F
=INDEX(B:B,L2)
G
=INDEX(C:C,L2)
H
=IFERROR(INDEX(B:B,M2),"")
I
=IFERROR(INDEX(C:C,M2),"")
J
=IFERROR(INDEX(B:B,N2),"")
K
=IFERROR(INDEX(C:C,N2),"")
L
=MATCH(E2,$A$1:$A$8,0)
M
=IFERROR(MATCH($E2,OFFSET($A$1,L2,0,COUNTA($A:$A)-L2),0)+L2,"")
N
=IFERROR(MATCH($E2,OFFSET($A$1,M2,0,COUNTA($A:$A)-M2),0)+M2,"")
Hope this helps, and let me know if you have any questions about the formulas.

Index match formula with multiple criteria without array

How do I add multiple criteria to this index match formula, which I pulled from a previous post, here: Use of INDEX MATCH to find absolute closest value.
=INDEX(B4:B10,MATCH(TRUE,INDEX(ABS(A4:A10-B1)=MIN(INDEX(ABS(A4:A10-B1),,)),,),0))
The formula above uses only one criteria while I need to use three Sample
I'm trying to use the same formula for a sample problem. I want to match cols B & D in table A to cols A & B in table B using the closest number in col C (table A) to output into table A, the corresponding col D from table B.
If you have an aversion to using Array Formulas [or if you would prefer not to for legitimate reasons, of which there are some], my recommendation is that you use a helper column to create a new unique ID.
For example, assume column A contains client Country, column B contains client State/Province, and column C contains client City. You would need all 3 to identify the geographic location of a client. So, create column D, as follows [starting in D2, and copied down]:
=A2&B2&C2
This will create a new field which shows CountryStateCity. If you want this to be displayed anywhere, you may want to add commas, as follows:
=CONCATENATE(A2,", ",B2,", ",C2)
Note that CONCATENATE is effecively the same as using '&'.
Now to search and find the client name in column E, which matches the geographic location [assuming that there's only 1 per city, but this is just an example anyway], do as follows:
=INDEX(E:E,MATCH("USA, Michigan, Detroit",D:D,0))

Fill out a column based on 2 other colums

I am trying to build a macro that will allow me to automatically fill out the cells in a column based on 2 criteria, which are the county and the project type, both of which are their own column names. The column to be filled out will be called "Frequency Band", which will have a static range of 12 possible values.
For example, if the County is "Bergen" and the Project Type is "2", then the Frequency Band will be "800Mhz". If it is the same county (Bergen) but the project type is "3", then the frequency band will be "1900MHz".
I currently have the list of Frequency Bands listed in another worksheet (Just call it sheet 2, cells E2 – E13), so I imagine that the outline of the VBA code would look something like:
If County(A) = Lee AND Project Type(B) = 2 Then Frequency Band(C) = 800Mhz(E3)
Else if Project Type = 3 Then Frequency Band = 1900MHz
Etc., Etc. for each county
Since I’ve never coded in VBA before and have no idea of its syntax, I don't really know where to begin with a formula like this. Could anyone help get me started?
Here is one way it would work with a formula.
In cells G1:K6 there is a table with your stored data (could also be on another sheet)
Column A you put in a country, column B you put in a project type (would be good if you validated against your source data.
Column C is your lookup function
'=INDEX($H$2:$K$6,MATCH(A2,$G$2:$G$6,0),MATCH(B2,$H$1:$K$1,0))
Index takes 3 main inputs:
the array (H2:K6) which is the actual frequency values
a row number in this array, and a column number in the array
For the row number lookup your country in the list you have (g2:g6) and it will tell you it is the x number in the array which corresponds to the row in the index array
Same thing with the column and project type.
There is a ton of information on the net about index and match if you need more information.
Highlighing is to show which values the formula has picked in my three examples below.

Excel: If Cell in Column = text value of X, then display text (in the same row, but different column) on another sheet

This is a confusing request.
I have an excel tab with a lot of data, for now I'll focus on 3 points of that data.
Team
Quarter
Task Name
In one tab I have a long list of this data displaying all the tasks for all the teams and what Quarter they will be on.
I WANT to load another tab, and take that data (from the original tab) and insert it into a non-list format. So I would have Quarters 1,2,3,4 as columns going across the screen, and Team Groups going down. I want each "task" that is labeled as Q1 to know to list in the Q1 section of that Teams "Block"
So something like this: "If Column A=TeamA,AND Quarter=Q1, then insert Task Name ... here."
Basically, if the formula = true, I want to print a list of those items within that team section of the excel document.
I'd like to be able to add/move things around at the data level, and have things automatically shift in the Display tab. I honestly have no idea where to start.
If there is never a possibility that there could be more that 1 task for a given team and quarter, then you can use a formula solution.
Given a data setup like this (in a sheet named 'Sheet1'):
And expected results like this (in a different sheet):
The formula in cell B2 and copied over and down is:
=IFERROR(INDEX(Sheet1!$C$2:$C$7,MATCH(1,INDEX((Sheet1!$A$2:$A$7=$A2)*(Sheet1!$B$2:$B$7=B$1),),0)),"")
I came across this situation. When I have to insert the values into a table from an Excel sheet I need all information in 1 Column instead of 2 multiple rows. In Excel my Data looks like:
ProductID----OrderID
9353510---- 1212259
9650934---- 1381676
9572474---- 1381677
9632365---- 1374217
9353182---- 1212260
9353182---- 1219361
9353182---- 1212815
9353513---- 1130308
9353320---- 1130288
9360957---- 1187479
9353077---- 1104558
9353077---- 1130926
9353124---- 1300853
I wanted single row for each product in shape of
(ProductID,'OrdersIDn1,OrderIDn2,.....')
For quick solution I fix it with a third column ColumnC to number the Sale of Product
=IF(A2<>A1,1,IF(A2=A1,C1+1,1))
and fourth Column D as a placeholder to concatenate with previous row value of same product:
=IF(A2=A1,D1+","&TEXT(B2,"########"),TEXT(B2,"########"))
Then Column E is the final column I required to hide/blank out duplicate row values and keep only the correct one:
=IF(A2<>A3,"("&A2&",'"&D2&"'),","")
Final Output required is only from Column E
ProductID Order Id Sno PlaceHolder Required Column
9353510 1212259 1 1212259 (9353510,'1212259'),
9650934 1381676 1 1381676 (9650934,'1381676'),
9572474 1381677 1 1381677 (9572474,'1381677'),
9632365 1374217 1 1374217 (9632365,'1374217'),
9353182 1212260 1 1212260
9353182 1219361 2 1212260,1219361
9353182 1212815 3 1212260,1219361,1212815 (9353182,'1212260,1219361,1212815'),
9353513 1130308 1 1130308 (9353513,'1130308'),
9353320 1130288 1 1130288 (9353320,'1130288'),
9360957 1187479 1 1187479 (9360957,'1187479'),
9353077 1104558 1 1104558
9353077 1130926 2 1104558,1130926 (9353077,'1104558,1130926')
You will notice that final values are only with the Maximum Number of ProductSno which I need to avoid duplication ..
In Your case Product could be Team and Order could be Quarter and Output could be
(Team,Q1,Q2,....),
Based on my understanding of your summary above, you want to put non-numerical data into a grid of teams and quarters.
The offset worksheet function will work well for this in conjunction with the match or vlookup functions. I have often done this task by doing the following steps.
In my data table, I have to concatenate the Team and quarter columns so I have a unique lookup value at the leftmost column of your table (Note: you can eventually hide this for ease of reading).
Note: You will want to name the input range for best formula management. Ideally use an Excel Table (2007 or greater) or create a dynamically named range with the offset and CountA functions working together (http://tinyurl.com/yfhfsal)
First, VLOOKUP arguments are VLOOKUP(Lookup_Value,Table_Array,Col_Index_num,[Range Lookup]) See http://tinyurl.com/22t64x7
In the first cell of your output area you would have a VLOOKUP formula that would look like this
=Vlookup(TeamName&Quarter,Input_List,Column#_Where_Tasks_Are,False)
The Lookup value should be referencing cells where you have the team names and quarter names listed down the sides and across the top. The input list is from the sheet you have the data stored. The number three represents the column number the tasks are listed in your source data, and the False tells the function it will only use an exact match in your putput.

Resources