VLookup of a VLookup - excel

All the single use VLOOKUP formulas work perfectly, but the formula below is a nested VLOOKUP and always fails.
=VLOOKUP(VLOOKUP(V2,PRAISe,2,FALSE)-VLOOKUP(D2,PRAISe,2,FALSE),Progress,2,FALSE)
When I step thought the formula the nested VLOOKUPS work fine and resolve to the correct decimal value. When the top level vlookup searches for that decimal value I always get a no value found error.
The lookup ranges are as follows:
PRAISE Lookup
1- 1.20
1+ 1.80
1= 1.50
2- 2.20
2+ 2.80
2= 2.50
etc. etc.
Grade Lookup
1.20 1-
1.50 1=
1.80 1+
2.20 2-
2.50 2=
2.80 2+
etc. etc.
Progress
0.00 0
0.30 1
0.60 2
0.90 3
1.20 4
etc. etc.
Things I have tried.
At first I thought it was due to the decimal places and an exact match problem, so I multiplied all my results by 10, so I was only working with whole numbers. Unfortunately I got the same result.
I have also tried spitting the formula across two columns. Again the subtraction works and resolves to a decimal number. However when I then try and look that number up as a separate statement it still fails.

This may be due to the way that numbers are stored in Excel. If you round the subtraction or use TRUE as the last argument in the outer lookup, the formulas seem to work. I changed V2 to A2 for sake of the screenshot.
=VLOOKUP(ROUND(VLOOKUP(A2,Praise,2,FALSE)-VLOOKUP(D2,Praise,2,FALSE),1),Progress,2,FALSE)
=VLOOKUP(VLOOKUP(A2,Praise,2,FALSE)-VLOOKUP(D2,Praise,2,FALSE),Progress,2,TRUE)
But there are combinations where the subtraction of the VLookup does not have an exact match in the Progress table, for example 2+ returns 2.8 and 1- returns 1.2. The subtraction result is 1.6 and a Vlookup with FALSE on the Progress table will return an error, while the vlookup with TRUE as the last parameter will return the next smallest match.
So check your V2 and D2 cells for combinations that are not found, and determine if you can get away with rounding or if you need to use TRUE in the outer lookup.

Aren't you missing some parenthesis in there to make it clear to the formulas the order of operations you intend?
=VLOOKUP((VLOOKUP(V2,PRAISe,2,FALSE))-(VLOOKUP(D2,PRAISe,2,FALSE)),Progress,2,FALSE)

Related

excel: sort a list of decimal values based on the order in another column

ID-A
Val-A
22
17.1
4
16.0
7
16.5
ID-B
Val-B
9
15.5
2
19.5
45
17.5
These tables (4 columns in Excel) are my input (here reduced to a minimal working example).
The order of the values in column Val-A (here: largest, smallest, middle) is the order, in which Val-B should be sorted.
That said, the second table should look like:
ID-B
Val-B
2
19.5
9
15.5
45
17.5
The order of the values in the input columns Val-A and Val-B as well as the IDs in ID-A and ID-B are arbitrary.
It is also important to note that the values in Val-A and Val-B are never equal, i.e. none of the values in Val-A will be a value in Val-B.
How can I achieve this in Excel?
I'm suggesting you rank the values in the first table, then match the ranks in the second table to those ranks to get the sort order that you need.
Using ranges:
=SORTBY(D2:E4,XLOOKUP(RANK(E2:E4,E2:E4),RANK(B2:B4,B2:B4),SEQUENCE(3)))
or using structured references:
=SORTBY(Table2,XLOOKUP(RANK(Table2[Val-B],Table2[Val-B]),RANK(Table1[Val-A],Table1[Val-A]),SEQUENCE(ROWS(Table2))))
EDIT
Case where second table has more rows than first.
A bit pushed for time on this so this isn't fully checked. I couldn't get Rank to work with filter, although the documentation suggestions that it should work, but it's OK with index. To avoid a lot of repetition, I've put it in a Let statement like this:
=LET(FilValB,INDEX(TableB[Val-B],1):INDEX(TableB[Val-B],ROWS(TableA)),
FilTableB,INDEX(TableB,1,1):INDEX(TableB[Val-B],ROWS(TableA)),
SORTBY(FilTableB,XLOOKUP(RANK(FilValB,FilValB),RANK(TableA[Val-A],TableA[Val-A]),SEQUENCE(ROWS(FilTableB)))))

Define List that Changes

I have a list of time records that have 1 digit, 1 decimal, 2 digits, and an "hrs" description.
I'm looking to only get the first 4 characters of my list. But my list isn't constant so I can't write a VBA code to backspace records from A2:A100 (example range).
I need help defining my list (because the range of records changes) and then keystroking three backspaces for every value in my list. The reason I use three backspaces is because I can use a color scale on my new list that is now stored as a Number.
Below is a snippet of what I'm working with:
Original List New List (I will use a color scale)
1.96 hrs 1.96
1.73 hrs 1.73
0.00 hrs 0.00
1.90 hrs 1.90
I will also consider simply being able to use a color scale on my original list. My only guess in achieving this would be to format the values on my original list as Numbers. However, I've tried changing the formatting but I still can't use a color scale.
Any help would be greatly appreciated!
You shouldn't need VBA. You can just use built-in formulas.
First four characters, converted to value:
=VALUE(LEFT(A2, 4))
Replace " hrs", convert to value:
=VALUE(SUBSTITUTE(A2, " hrs"))
There are lots of other ways to do it.

How to Sum only hours using Sumif() from excel

I am Calculating Over Time of the employees in time format cell using Microsoft Excel 2007. In my result, its calculated as hh and mm. But I want only Hours and ignore Min.
Eg : I have to get this result of SANIA SARWER 0.18 as 0.0
See the screenshot below.
=SUMPRODUCT(Int(24*$B:$B),--($A:$A=D2))
How does it work?
Well, SUMPRODUCT will go through each item and multiply them together (So SUMPRODUCT(A1:A3,B1:B3) is the same as =(A1*B1)+(A2*B2)+(A3*B3)) - now, let's looks at each of the columns we're multiplying.
INT(24*$B:$B) is just Days, converted to Hours, and trim off the decimal part (minutes/seconds) - fairly simple.
--($A:$A=D2) first checks if the value in column A is the same as in D2 and gives TRUE or FALSE. The -- then converts this into 1 or 0, which we multiply by the hours before adding them all up.
Easiest way would be to Round Down the data using ROUND function, and then use SUM function to add the rounding data up.
You can find a simple example below.

Showing incorrect sum in excel row sum formula

Formula =(N59 -O59 - P59 - R59)
working fine for most rows but for some rows, the sum is 0 - but it is showing a strange value like -7.27596E-12
I have tried many thing but I don't know what I am missing
Because computer math isn't exact in decimal, so 0.1+0.9 is not necessarily exactly 1.0. The notation "E-12" means "times ten to the minus twelfth," which is tiny.
Here's a forum thread on the subject, and here's the official Office documentation. If you change the cell format from General to Number, you can set how many digits you want. E.g., if you select 2 digits, 0.001 or anything smaller will round down to display as 0.

Calculating my tax automatically in Excel

It's my very first post here so hi all.
I did a lot of research before hand but couldn't find the answer I was looking for.
I want a spreadsheet in Google Sheets to automatically calculate my tax.
€0 - €11000 w/ 0%
€11000 - €18000 w/ 25%
€18000 - €31000 w/ 35%
€31000 - €60000 w/ 42%
€60000 - €90000 w/ 48%
€90000 - €1000000 w/ 50%
€1000000+ w/ 55%
So the first 11k are taxed with 0% the next 7k are taxed with 25% etc.
What I've had the following thought - give that F9 are my before tax earnings:
=IF(0<=F9<=11000,SUM(F9*0%),(IF(11000<F9<=18000,SUM((F9-11000)*25%),(IF(18000<F9<=31000,SUM((7000*25%)+((F9-18000)*35%),SUM(F9))))))
Unfortunately it just won't work.
Am I using the right function?
Is there anything out there which would make it much easier?
Thank you for your help.
Here is an example (Excel) for your problem:
In Cell A1 is your Money, paste the code in A2 for example:
=WENN(A1>10000;"10%";WENN(A1>7000;"7%";WENN(A1>5000;"5%";WENN(A1>3000;"3%";"0%"))))
FK
Excel does not work that way X<y<z. Plus it resolves in order so it is not necessary:
=IF(F9<=11000,SUM(F9*0%),(IF(F9<=18000,SUM((F9-11000)*25%),(IF(F9<=31000,SUM((7000*25%)+((F9-18000)*35%),SUM(F9))))))
if it is less than 11000 then the first will fire and none others. then if greater than 11000 but less than 18000 the second will fire, and so on.
List values of each bracket range with the percentage applied if it is above that amount, for example:
A B
1 11000 0.25
2 18000 0.35
3 31000 0.42
4 60000 0.48
5 90000 0.50
6 1000000 0.55
You can format the percentage values as percentages if you prefer. What is important is that the value is a decimal and not a string.
Then you can use the MATCH function to determine the row of the first value that is larger than your income. So if the cell holding your income is F9, you'd have:
=MATCH(F9;A1:A6;1)
But this only returns the row number. If we want to retrieve the tax applied, we'll need to use this to pinpoint the value in column B pertaining to that. To get a value pertaining at a certain point dynamically, we use INDEX.
So putting it together, you'd have:
=INDEX(B1:B6; MATCH(F9; A1:A6; 1); 1)
One minus this times the value in F9 to get the amount after taxes:
=F9*(1 - INDEX(B1:B6; MATCH(F9; A1:A6; 1); 1))
Why would you do it this way? It lets you change the values in an intuitive fashion without having to parse a long and arduous formula. You can also add new values with relative ease. Just remember to adjust the A1:A6 and B1:B6 ranges.
Good luck! Let me know how it turns out!
You might want to try this:
=if(F9<=0,"Error",IF(F9<=11000,0,(IF(F9<=18000,(F9-11000)*25%,(IF(F9<=31000,1750+(F9-18000)*35%,IF(F9<=60000,6300+(F9-31000)*0.42,if(F9<=90000,18480+(F9-60000)*0.48,IF(F9<=1000000,32880+(F9-90000)*0.5,487880+(F9-1000000)*0.55)))))))))

Resources