Excel. Use information from two different sources - excel

I am trying to find the assigned tax rate for each individual based on the country and annual income from picture below by referring to 2.
Thank you!
=IF(OR(G6=0,G6=-1),0,INDEX(INDEX(TaxRates!D:D,MATCH(A7,TaxRates!A:A,0)):INDEX(TaxRates!D:D,MATCH(A7,TaxRates!A:A,0)+COUNTIF(TaxRates!A:A,A7)-1),MATCH(J7,INDEX(TaxRates!B:B,MATCH(A7,TaxRates!A:A,0)):INDEX(TaxRates!B:B,MATCH(A7,TaxRates!A:A,0)+COUNTIF(TaxRates!A:A,A7)-1),1)))

Assuming that
both worksheets start in column A
row 1 has column headings
formula starts in row 2 on People sheet
data in the TaxRates sheet is sorted ascending by country and then ascending by lower income
you may want to add a row for 0 to first lower bound for each country.
Read the formula from inside out. It first establishes a lookup range that goes from the first occurrence of the given country to the last row with the given country, then does an approximate match on the lower bound income for these rows.
=INDEX(INDEX(TaxRates!D:D,MATCH(A2,TaxRates!A:A,0)):INDEX(TaxRates!D:D,MATCH(A2,TaxRates!A:A,0)+COUNTIF(TaxRates!A:A,A2)-1),MATCH(I2,INDEX(TaxRates!B:B,MATCH(A2,TaxRates!A:A,0)):INDEX(TaxRates!B:B,MATCH(A2,TaxRates!A:A,0)+COUNTIF(TaxRates!A:A,A2)-1),1))

Related

Using LOOKUP Functions with <= and >=

I attempting to use the LOOKUP functions in Excel in a nested(?) fashion and with ranges of data. In the attached picture, the left-hand table is my data that extends for another 360 rows or so. Each row has a unique ID (I've taken this data from a larger set so I wanted to retain it), a State postal abbreviation, and the income level for that data point (each row is data from a different zipcode).
The table on the right is the metadata - quintile levels for income in each state. For each row on the left, I want to look up the state abbreviation from the metadata, then use the adjacent income level to determine and print out the appropriate quintile based on that row in the metadata. I anticipate that the solution would use some form of the lookup functions and inequalities, but I'll take any solution.
For this approach you need Office 365, with the new XMatch function, which can do an approximate match for next bigger number without requiring the data to be sorted.
The formula is
=INDEX($J$1:$N$1,XMATCH(C2,INDEX(J:J,MATCH(B2,H:H,0),0):INDEX(N:N,MATCH(B2,H:H,0)),1))
If you don't have XMatch, you would need to re-arrange the lookup columns from Highest to Lowest. Then you can use
=INDEX($J$1:$N$1,MATCH(C2,INDEX(J:J,MATCH(B2,H:H,0),0):INDEX(N:N,MATCH(B2,H:H,0)),-1))
If you paste this formula on cell D4, would the result be your expected output?
(Highest Quintile for California)
=INDEX(N:N,MATCH(B4,B:B,0))
Paste this to D5
(Lowest Quintile for Ohio)
=INDEX(J:J,MATCH(B5,B:B,0))
The last 0 (zero) in the formula is the match type. It can be replaced with:
1 - less than
0 - exact match
-1 - greater than
depending on your need. Did I get your point?
Your information is a bit sparse. So I tell you what I did and you take it from there.
First I created a named range to comprise 2 columns of your median income table, state and income. Then I created this formula to extract the income by state.
=VLOOKUP($B2,Income,2,FALSE)
Observe that the state name is in column B and the income in the 2nd column of the Income range. Your list may be structured differently. The key to it is that the Income range must have the State in its first column and the 2 in the formula just counts columns from State to Income.
If you place this formula on the same sheet as the Income range it will just produce a copy of the Income column. But that isn't what I did. I placed it in a blank column on the Quintile tab. That happened to be column J, since A:G is taken up with your data, notably, C:G with the columns for quintile numbers. Observe in this transfer that column B displays the state abbreviations. By coincidence it's column B in both sheets. The relevant column is the one on the Quintile sheet. So, the formula still shows the median income for each state but the sequence is determined by the sequence of state names on the tab where the formula resides, and that is the requirement here.
Next, I created this formula and placed it in column K of the Quintile sheet.
=MATCH(J2,C2:G2,1)
This formula determines the column in C:G where the value in J2 is matched. J2, of course, contains the Median income drawn by the VLOOKUP. If that number is nothing it will be interpreted as zero and the lowest quintile returned. Read up on the precise method of the MATCH function.
Now J2 can be integrated into the formula. I did that in a copy of the MATCH formula in column L.
[L2] =MATCH(VLOOKUP($B2,Income,2,FALSE),C2:G2,1)
Observe that the formula in K and L have the same result. I copied them down a few rows to make sure. I got a lot of #N/A errors in this exercise resulting from state abbreviations in the Quintile sheet not being found in the Income range. I think that information is useful. Therefore I didn't suppress it.
The result so far is the quintile, numbered from 1 to 5. I wanted to make sure that the numbers are correct. Therefore I "translated" them to the number in the Quintile table.
For this purpose I created another named range, called this one "Quintiles", comprising of columns C:G. It's important that this range should start in row 1. The columns could be any other columns (not C:G) but they must be the same as specified in the formula, with the lowest quintile being the first. And this became my formula in column M.
[M2] =INDEX(Quintiles,ROW(),L2)
If you actually need this number you can replace the reference to L2 in the formula with the formula in L2.

How to use index function with two dimensional table

The Discount worksheet contains a two-dimensional table that has been set up to find the discount category of a ticket based on the weekday of travel and the fare category. In cell J3 of the Request worksheet, use the INDEX function to retrieve the discount category for this ticket, Copy down formula. I have =INDEX((Discounts!$A$4:$A$10,Discounts!$B$4:$D$10),4,2,2) but that isn't correct...First Table is Request TableDiscount Category Table
The syntax for the Index formula is:
(ARRAY, row num, column num)
Basically, an array is a rectangular shape of data. Row number tells excel whether to look in the 1st row, second row, third row, etc. Column num is the same thing for columns.
Your array should be Discounts!$A$4:$d$10
Let's say you're trying to find the discount for the first example (John Frasier)
Your row number is the day of the week, so it should equal h3.
Your column number is the fare category, so it should equal I3
Thus the whole formula should be
=index(Discounts!$A$4:$d$10,H3,I3)

How to return the cell contents based on matching heading and row labels

I have an Excel table where the column headings are companies, and the row labels are dates. e.g.
Company A Company B Company C
25/03/2018 50
03/04/2018 10
13/06/2018 25
13/06/2018 10
06/07/2018 10
All column headings are unique but sometimes row labels will have the same dates.
On another sheet I will have rows stating the date and company name. What formula should I use to get the value that corresponds to the intersection of the company name and date provided?
I can use MATCH to tell me the Company Column I should be looking at, but don't know how to tell it to search the dates next to the entries in those columns. VLOOKUP seems to get tripped up by the fact that sometimes the Row label isn't unique.
sometimes the Row label isn't unique instead of VLOOKUP try SUMIF:
=SUMIF($A:$A,DATE(2018,6,13),INDEX($B:$D,0,MATCH("Company A",$B$1:$D$1,0)))
Adjust cell references to suit your actual data. Note that you can replace the DATE(2018,6,13) and "Company A" with cell references.

Getting a cell value from another sheet; the cell has a known column number but un-known row number

I’ve conducted an experiment where each participant played three game trials.
The events that the participant has gone through in each trial is logged in an Excel workbook as sheet "Ex1", sheet "Ex2", and sheet "Ex3"
The last non-empty row of each sheet has a score value of the game trial (number of rows varies depending on the number of events that the participant made during the game trial).
The cell that contains the score value has a known column which is (column E), but unknown row number
In a fourth sheet "Summary", I want to type in three cells score1, score2, and score3
Then beneath them, I want to read the score value from the three sheets.
Can anyone help with that?
Thanks,
Try this formula. It will grab the value from last row in Column E:
=INDIRECT("E"&SUMPRODUCT(MAX(($E:$E<>"")*(ROW(E:E)))))
Is there a maximum number of rows per sheet? If so, set your score value to be that number +1 (to be safe) and use that number as your row marker for the code.
If the score value has a known column, it's also possible to simply move the row from unknown to row 1 and separate it from the entry columns by x number of rows (say, 3 in this case) and use row 1, column H instead of E.

Check if Cell value exists in Column and return a sum for a value in the same row but different column for each occurance

My end goal is to have a Column of salesmen and they're total amount earned in the next Column. I have a data sheet that has their name next to each sale they made. So I want to consolidate to just their name and the total amount of their sales in a new table. The data table will continue to grow.
For the basics, one minute should be ample. Select a range that includes names and sales (here A1:B7), Insert > Tables – PivotTable, PivotTable, OK, then drag the name field into Row Labels and the sales field into Σ values:
Then just play around, click a few button and see what happens - and explore other advice (on SO and elsewhere) because that is only the 'tip of the iceberg' in terms of how they may well be able to help you.

Resources