I have a cell where I want to get the tax% based on a criteria
Coming from "Taxes", depends on manufacturer country, year of release and car type
I've tried to use search and index and its not working at all, I need the cell to check values in the manufacturer country, year of release and car type use these inputs go to the Taxes sheet and get the value
Before I start, I should come clean and say I am an evangelist for the OFFSET() function, and a mortal foe of INDIRECT().
Let's assume that the number of vehicle types (TRUCKS, SEDANS, ....) is the same for each country, ie 8. (If its not then that can be worked around with a bit more effort). You could put this number in a cell somewhere and use it when you need the number of types.
Also, let's say the first column in your screenshot is column A. And that the cell A1 contains "China".
Let's say we are looking for the tax rate in 2009, for SEDANS in France.
Function 1:
=MATCH("France",$A:$A,0) will return 14 (if I have counted correctly)
... ie cell A14 contains the word "France".
On the assumption that the years are the same for all countries we can use any of the header rows to find the right column.
Function 2:
=MATCH(2009,$3:$3,0)-1 will return 8 I think.
If your years are just strings of text, then replace 2009 with "2009".
Because your Types are not in the same order in each table (why?) we need an extra step.
Function 3:
=MATCH("SEDANS",OFFSET($A$1,(Result of f1) -1 + 3,0,8,1),0) should return 3.
What is the maths in the OFFSET function? I need to go down (14-1) rows from cell A1 to get to "France". From there I need to go down another 3 rows to get to the first of the list of Types, and there are 8 types to search in. I'm then looking at a range of cells which is 8 rows x 1 column.
Now you can extract your tax rate, using
Function 4:
=INDEX(OFFSET($A$1,(Result of f1) -1+3,1,8,100),(Result of f3),(Result of f2))
(I've put 100 as I don't know how many columns of years you have. You could use something like =COUNTA($3:$3)-1 if there was nothing else in the 3rd row after the last date).
I would put the results of each function in a cell while you test this. Once you are happy that each step is working correctly you can nest all the various functions together, or alternatively just put some extra columns on the right hand side of your results table, which you can Hide if you want to.
EDITED: To add some $ on cell references to lock the "origin" of the data.
If your tax tables are real Tables, each NAME'd with the name of the respective country, you can use something like:
=VLOOKUP(H13,INDIRECT(H12),MATCH(TEXT(H14,"0"),INDIRECT(H12 & "[#Headers]"),0))
where
H12 contains the name of the country
H13 contains the Type of vehicle
H14 contains the Year
eg:
You'll need to adapt this to your real ranges, but this provides an approach.
I'd suggest using dropdown lists (from Data Validation) in H13:H14 in order to avoid typos.
If you want to avoid using Tables and also the volatile functions OFFSET and INDIRECT (because if you have a lot of volatile functions they can impair performance of your worksheet) you can try the non-volatile, but longer and more obscure:
=VLOOKUP($H$13,INDEX($A:$A,MATCH($H$12,$A:$A,0)):INDEX($D:$D,LOOKUP(2,1/($A:$A<>""),ROW($A:$A))),$H$14-2000,FALSE)
In the above, you'll have to make adjustments
Assumptions are:
The country name is above the relevant tax table
Tax table starts in Column A
Change references to Column A if it does not start there.
Change the reference to Column D to the last column of your tax table (or even further if you will be expanding it).
The Year columns are labelled the same for all countries (eg: consecutive years starting at 2002)
$H$14-2000 calculates the column argument for the VLOOKUP function.
Related
I looked up values from another sheet with the following formula:
=IFERROR(INDEX('Detail list'!$H$2:$H$1604;SMALL(IF(1=((--(A$1='Detail list'!$J$2:$J$1604))*(--(A$2='Detail list'!$I$2:$I$1604)));ROW('Detail list'!$H$2:$H$1604)-1;"");ROW()-2));"")
This lookup is based on two criteria: Company name and year.
The lookup happens in cell A3 and onwards. It uses the company name in A1 and the year from A2 and then finds a corresponding value in another sheet. There's duplicates involved here since the column that is used for this look up consists only of 001 up til 010. It still is able to return all the values in the correct sequence based on year and company name.
I now want to look up or couple a 'corresponding' value with the value that was just acquired. For example: The value in A3 (005) refers to a specific cell in the other sheet. I want to return a value from that exact row but a different column. I have tried the following:
=IFERROR(#INDEX('Detail list'!$B$2:$B$1604;AGGREGATE(15;6;(ROW('Detail list'!$H$2:$H$19883)-ROW('Detail list'!$H$1))/('Detail list'!$H$2:$H$19883=A3);COUNTIF($A$3:$A3;A3)));"")
This does return a value (namely a client value) but this it is not precise as it takes the first 005 it comes across in the full list (so no longer sorted on year and company!) and reports that. I need it to be from the exact row the previous value is referring to.
I'd be so happy if anyone could help me out with this one. If not, I understand completely,
Kind regards,
VHes
Keeping references consistent and clear across sheets while nesting statements can be tricky. Have you considered pasting the data from 'Detail List' into your current sheet and using something like VLOOKUP or INDEX that way?
Another possible solution would be to throw everything into a pivot table and use the filters to get what you need. Not sure if either of these apply to your task.
I have a data in Excel as shown in attached image where in I've used named ranges.
Spends. Apr18. May18. Jun18
Category A. 120. 120. 120
Category B. 135. 125. 129
Category C. 110. 111. 112
Name Range: Spends
Range: =Sheet1!$A$1:$D$4
The average quarterly spends are calculated using named references as:
=AVERAGE(INDEX(Spends,2,2):INDEX(Spends,2,4))
This returns 119 in Cell E2
How can I drag this formula to subsequent cells so that it is applied automatically.
If you use the INDEX function with constants, of course these constants will not change when you drag the formula down and/or across.
You will need to learn about absolute and relative references and use something like Row(A1) and/or Column(A1) instead of the constants 2 and 2.
But maybe it does not have to be that complicated.
You could just add a column in the data table that calculates the Average and refer to that cell.
Or, in cell E2, use the formula =average(B2:D2).
I don't see the need for the named range at all in this scenario. It only complicates things.
It seems that you are struggling with appropriate data architecture concepts rather than with using formulas.
If in doubt, keep it simple. I don't see an application for copying the formula across, since you only have three months of data and you want to average these three months.
If your real scenario has more columns, then, please!!, update your question and post more relevant context. Then post a comment, so I can see you made a change.
Again, since you are new here: do not post updates into comments. Edit your question and then post a comment.
Use the ROW() function to return the relative position
E.g. in E2 and drag down
=AVERAGE(INDEX(Spends,ROW(),2):INDEX(Spends,ROW(),4))
Maybe you want to dynamically find the quarter start and end columns then you can use Match function to find the dates and return the position (column) where found. Then feed these into your formula:
Getting the columns by searching for qtr start and end:
Referencing those found positions as column arguments in your formula:
I have a Simple spreadsheet with 2 rows:
ActualJAN | BudgetJAN | ActualFEB | BudgetFEB | ActualMAR | BudgetMAR ....
100 200 300 400 500 600 ....
I'd like to sum ONLY the Budget columns up to the current month (Month(Today()).
Same for the Actual columns.
So if we're currently in February,
Budget to date would be: 600=200+400
Actual to date would be: 400=100+300
I just can't seem to get there, at least simply and elegantly.
This is a non array formula that performs array like operations. As such large range references should be avoided or you will experience a slow down or potential crash of your system. For a small defined range works great so long as the formula is not repeated too many times either.
Additionally TODAY() is a volitile function which means the formula will recalculate whenever anything in the spreadsheet changes, not just when something related to the formula changes.
This formula is generalized a bit so your data can be located anywhere on your sheet and does not require rearrangement of your data.
To get your actual sum use the following:
=SUMPRODUCT($C$4:$H$4*(COLUMN($C$4:$H$4)-COLUMN($C$4)+1<=MONTH(TODAY())*2)*(LEFT($C$3:$H$3)="A"))
To get your Budget sum use the following:
=SUMPRODUCT($C$4:$H$4*(COLUMN($C$4:$H$4)-COLUMN($C$4)+1<=MONTH(TODAY())*2)*(LEFT($C$3:$H$3)="B"))
Change C4:H4 to suit your number range. ChangeC3:H3 to suit your column title range. Change C4 to be the first cell of your number range.
Caveat: Assumes maximum 12 months starting at January
Proof of concept:
I would recommend structuring your data differently. It would be an easier task if you arrayed everything vertically and divided your data into three columns. The first would be Category, which would be populated with either "Budget" or "Actual." The next column would be Month. After that, of course, you have the Value column. Then, use a basic SUMIF, like "=SUMIF(A1:A6,"Budget",C1:C6)." A1:A6 is the range Excel will scan for the desired variable. In this case, that variable is "Budget." Then, C1:C6 is the value that corresponds to a "Budget" month. That formula will give you the answer you want as long as you expand the SUMIF formula to include the full range of values, e.g., "SUMIF(A1:A317,"Budget",C1:C317)."
So I think I understand what you're trying to do, I cannot make the entire formula without the rest of the spreadsheet but this is working currently:
For the Actual:
=IF(MONTH(TODAY())=1,A2,IF(MONTH(TODAY())=2,A2+C2,IF(MONTH(TODAY())=3,A2+C2+E2,"")))
For the Budget:
=IF(MONTH(TODAY())=1,B2,IF(MONTH(TODAY())=2,B2+D2,IF(MONTH(TODAY())=3,B2+D2+F2,"")))
Here is the spreadsheet I created to test:
If you give me the rest of the data I can complete the formula, basically all you would need to do is add more months to the formula and change the amounts it adds.
I am sure there is probably a more efficient way to accomplish this but this way works.
I suggest a hidden row to control your dates. Say, January is in column C, enter [C1] =1, [D1] =C1, [E1] =C1+1, [F1] =E1. Select E1:F1 and copy to the right until December. Hide row 1.
In row 2 use these two formulas.
[C2] ="Actual" & UPPER(TEXT("1/" & C$1,"mmm"))
[D2] ="Budget" & UPPER(TEXT("1/" & D$1,"mmm"))
Select C2:D2 and copy to the right until December. This exercise isn't required because the resulting display is exactly what you already have. But producing this result with the help of formulas ensures freedom from error, and it is faster. As an added bonus you get a visual check of what's in the hidden row.
Now you can use this formula to extract totals from row 3 where you have your values.
=SUMIFS($C3:$Z3,$C$2:$Z$2,"Budget*",$C$1:$Z$1,"<="&MONTH(TODAY()))
Change "Budget" to "Actual" and the same formula will extract the actual amounts.
I work for a company that has multiple locations selling auto parts. I'm wanting to look at the 'freshness' of the inventory, but for a specific year range for specific vehicle(s).
The basic formula I'm using is
=COUNTIFS(INVENTORY!$A$2:$A$50000,$B$1,INVENTORY!$I$2:$I$50000,$J$117,INVENTORY!P$2:P$50000,$C$118)
Result is 4
The first argument is looking at the location, the second is looking at the particular vehicle. The third is determining whether the inventory is either 30, 60 or 90 days old, and I'm getting the right information. What I want to know now is, while looking at those 4 vehicles, how many of those are made between the years 2004 to 2010, so the criteria for the 4th argument has a range within it, not one specific year (I know the result should come back as 1 in either the 30, 60 or 60+ cell). On the inventory sheet, the years of the vehicles are in column 'E'. I'm not sure if I need to use imbedded IF statements to specify the year range, or need to rewrite the whole formula. Can anyone give me some advise on how to write the formula to get this info?
You can add two conditions to your COUTINFS on the same E column for the year, i.e.
=COUNTIFS(INVENTORY!A:A,$B$1,INVENTORY!I:I,$J$117,INVENTORY!P:P,$C$118,
INVENTORY!E:E, ">=2004", INVENTORY!E:E, "<=2010")
The second line above shows the additional consitions. If the range of years is dynamically present in cells, say C1 and D1, the criteria should be composed by concatenation, i.e.
=COUNTIFS(INVENTORY!A:A,$B$1,INVENTORY!I:I,$J$117,INVENTORY!P:P,$C$118,
INVENTORY!E:E, ">="&C1, INVENTORY!E:E, "<="&D1)
' ^^^^^^ ^^^^^^
EDIT *
A JAN FEB MAR APR
1<drpdwn> A1+JAN A1+FEB A1+MAR A1+APR
what i need is for B1 to hold a formula that will take A1+B as a string and use this as the name of a Table to grab a value from. so something like
=INDIRECT($A1&"B")[[#Totals],[Column7]] so the cell will display the value in column 7 in the totals row for a table that is named the result of '=INDIRECT($A1&"C")' =B2&A3 also works for creating the variable, but again. unable to use in the above formula
Hopefully this is a little bit clearer
As an example, I will have 12 tabs that lets say are months, JAN FEB MAR etc... these are the column headers in my above.
Within these will be various Tables, like Expenditure, income, etc... they will be named ExpenditureJAN, ExpenditureFEB.
I want a simple (overview) tab, that lets me select expenditure in A1, and each months columns will use the formula to display a value from its relevant table, so A(JAN) would display jan's expenditure total etc.....
=ExpenditureJAN[[#Totals],[Column7]] this would work, but i need the expenditure bit, to change to what ever is selected from a picklist in A1.
***Old Question - Before edit -
Didn't know how to word the question, but here is my problem;
I have tables called AB, AC, AD, BB, BC etc...
I want to look up the following =AB[[#Totals],[Column7]] which works fine. However.....
I want it to change AB to be the string created from two cells so for instance =A3&B2[[#Totals],[Column7]]
Hopefully that makes sense, i am struggling to put this into words for some reason.... To add to this, A3 will be a drop down list, so the idea is, i change the value in A3 and it will change the table each cell the formula is in to look at the correct value.
B C D E
# #B #C #D #E
So # can change via a picklist, and the formula will detect this change and fire off to look at #totals, column 7 in the table #B/#C etc.. using the column headers and picklist as references for the table name.*
As user3514930 stated you want to use the INDIRECT function. Given the following table:
A B C D E
1<drpdwn> #B #C #D #E
If Cell B1 contains the formula =INDIRECT($A1&"B") it would show whatever is selected in cell A1 immediately followed by the character B. So drag that over to fill the rest of the row and update the trailing letter to =INDIRECT($A1&"C"), =INDIRECT($A1&"D"), =INDIRECT($A1&"E") etc. in the formulas.
Then when the dropdown box in cell A1 is changed, say to C the table would look like this:
A B C D E
1 C CB CC CD CE
Edit: So I got this to work like you wanted using INDEX, INDIRECT, and an additional cell to reference the table desired. I setup a table like you suggested named ExpendituresJAN. It had 6 columns, first was Week1-Week4, then HR, IT, Admin, Sales, and Payroll for departments, and then Column7 where I had totals per week. I threw in some random numbers (IT had a heck a week 3, spending nearly $997k evidently, and the sales department outdid itself with it's end of month party running over $10k, but those boys do love to party!). Sorry, where was I? Oh yes, example table, I added a Totals row on, and went to trying to figure it out because INDIRECT really seemed to be the key and I just had to wrap my head around things.
Next sheet had basically 4 cells with anything in them. A2 had a dropdown where I could Choose JAN, FEB, or MAR. B1 said JAN (I imagine C1 would say FEB, but I didn't go that far). B2 said #REF! a lot of the time.
________| JAN
<drpdwn>| #REF!
In the end A2 was moved down to A3 for my dropdown box, and row 2 was hidden, I'll get to why that is in a second. Ok, how to reference that... I can't seem to do it traditionally with structured reference, which is a pain, but there's got to be a way around it. I crack my knuckles, pull up Chrome, and practice a little Google-fu. Turns out what we needed was INDEX, which will return a cell or range from a table by name. B2 (hidden now) now contains the formula ="Expenditures"&A3 which, when JAN was selected read ExpendituresJAN. Excellent, I'm pretty sure we're most of the way there now. I just have to phrase my INDEX right and I'm set.
So, INDEX ended up being relatively simple all in all, but there's a catch. No #Totals row accessibility for INDEX. I got hung up on that for a few minutes until I stepped back and thought "wait, what's my totals row except a =SUM() formula? Ok, I can duplicate that. INDEX works with this syntax: INDEX(array/table, Row#, Col#) but you can use 0 for the row and it takes the entire row into account. Perfect for what I want, since I want a sum of Column7, I'll just wrap the INDEX in a SUM function.
=SUM(INDEX(INDIRECT(B2),0,7))
That spits back $1,036,371.00, the exact same thing my totals row shows for Column7. The only complication I could see is if your different tables have different Totals rows, as in one does a SUM, one does an AVG, and what not. Then the formula starts getting a bit more complex.