Index Match to replace a Vlookup

admat

New Member
Joined
Dec 20, 2018
Messages
20
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
Platform
  1. Windows
[FONT=verdana, geneva, lucida, lucida grande, arial, helvetica, sans-serif]Good day,
[/FONT]I have a table that stores rates for NI Contributions called Rates and I have been using a Vlookup to return the Rate based on the employee Salary like this

VLOOKUP(I4,'NIS AND TAX TABLE'!$E$2:$F$18,2)

Now that the rates have been increased (highlighted in the Rates Table attachment), how to get the new rates if I update the current Rate Table using the Effective Date. Thanks to ExcelIsFun's YouTube video

https://www.youtube.com/watch?v=EMDIkP76WkU

I've tried this:

{=INDEX(Rates[EMPLOYEE CONTRIBUTION],MATCH(AGGREGATE(14,6,Rates[EFFECTIVE DATE]/((Rates[MONTHLY SALARY]<[@GROSS])*(Rates[EFFECTIVE DATE]<=[@[PAY PERIOD END]])),1)&[@GROSS],INDEX(Rates[KEY],0),1))}

Although it returns values, I am not getting the correct results.

[TABLE="width: 796"]
<tbody>[TR]
[TD][TABLE="class: grid, width: 796, align: center"]
<tbody>[TR]
[TD]EFFECTIVE DATE
[/TD]
[TD]CLASS
[/TD]
[TD]KEY
[/TD]
[TD]MONTHLY SALARY RANGE
[/TD]
[TD]MONTHLY SALARY
[/TD]
[TD]EMPLOYEE CONTRIBUTION
[/TD]
[TD]EMPLOYEER CONTRIBUTION
[/TD]
[TD]CLASS Z
[/TD]
[/TR]
[TR]
[TD]03/09/2016 [/TD]
[TD]1
[/TD]
[TD]42616867
[/TD]
[TD] 867 - 1472.99
[/TD]
[TD] 867.00
[/TD]
[TD] $ 11.90
[/TD]
[TD] $ 23.80
[/TD]
[TD] $ 1.79
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]2
[/TD]
[TD]426161473
[/TD]
[TD] 1473 - 1949.99
[/TD]
[TD] 1,473.00
[/TD]
[TD] $ 17.40
[/TD]
[TD] $ 34.80
[/TD]
[TD] $ 2.61
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]3
[/TD]
[TD]426161950
[/TD]
[TD] 1950 - 2642.99
[/TD]
[TD] 1,950.00
[/TD]
[TD] $ 23.30
[/TD]
[TD] $ 46.60
[/TD]
[TD] $ 3.50
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]4
[/TD]
[TD]426162643
[/TD]
[TD] 2643 - 3292.99
[/TD]
[TD] 2,643.00
[/TD]
[TD] $ 30.10
[/TD]
[TD] $ 60.20
[/TD]
[TD] $ 4.52
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]5
[/TD]
[TD]426163293
[/TD]
[TD] 3293 - 4029.99
[/TD]
[TD] 3,293.00
[/TD]
[TD] $ 37.20
[/TD]
[TD] $ 74.40
[/TD]
[TD] $ 5.58
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]6
[/TD]
[TD]426164030
[/TD]
[TD] 6030 - 4858.99
[/TD]
[TD] 4,030.00
[/TD]
[TD] $ 45.10
[/TD]
[TD] $ 90.20
[/TD]
[TD] $ 6.77
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]7
[/TD]
[TD]426164853
[/TD]
[TD] 4853 - 5632.99
[/TD]
[TD] 4,853.00
[/TD]
[TD] $ 53.20
[/TD]
[TD] $ 106.40
[/TD]
[TD] $ 7.98
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]8
[/TD]
[TD]426165633
[/TD]
[TD] 5633 - 6456.99
[/TD]
[TD] 5,633.00
[/TD]
[TD] $ 61.40
[/TD]
[TD] $ 122.80
[/TD]
[TD] $ 9.21
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]9
[/TD]
[TD]426166457
[/TD]
[TD] 6457 - 7409.99
[/TD]
[TD] 6,457.00
[/TD]
[TD] $ 70.40
[/TD]
[TD] $ 140.80
[/TD]
[TD] $ 10.56
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]10
[/TD]
[TD]426167410
[/TD]
[TD] 7410 - 8276.99
[/TD]
[TD] 7,410.00
[/TD]
[TD] $ 79.60
[/TD]
[TD] $ 159.20
[/TD]
[TD] $ 11.94
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]11
[/TD]
[TD]426168277
[/TD]
[TD] 8277 - 9272.99
[/TD]
[TD] 8,277.00
[/TD]
[TD] $ 89.10
[/TD]
[TD] $ 178.20
[/TD]
[TD] $ 13.37
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]12
[/TD]
[TD]426169273
[/TD]
[TD] 9273 - 10312.99
[/TD]
[TD] 9,273.00
[/TD]
[TD] $ 99.40
[/TD]
[TD] $ 198.80
[/TD]
[TD] $ 14.91
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]13
[/TD]
[TD]4261610313
[/TD]
[TD] 10313 - 11396.99
[/TD]
[TD] 10,313.00
[/TD]
[TD] $ 110.20
[/TD]
[TD] $ 220.40
[/TD]
[TD] $ 16.53
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]14
[/TD]
[TD]4261611397
[/TD]
[TD] 11397 - 12652.99
[/TD]
[TD] 11,397.00
[/TD]
[TD] $ 122.10
[/TD]
[TD] $ 244.20
[/TD]
[TD] $ 18.32
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]15
[/TD]
[TD]4261612653
[/TD]
[TD] 12653 - 13599.99
[/TD]
[TD] 12,653.00
[/TD]
[TD] $ 133.30
[/TD]
[TD] $ 266.60
[/TD]
[TD] $ 20.00
[/TD]
[/TR]
[TR]
[TD]03/09/2016
[/TD]
[TD]16
[/TD]
[TD]4261613600
[/TD]
[TD] 13600 and over
[/TD]
[TD] 13,600.00
[/TD]
[TD] $ 138.10
[/TD]
[TD] $ 276.20
[/TD]
[TD] $ 20.72
[/TD]
[/TR]
[TR]
[TD]20/12/2018
[/TD]
[TD]8
[/TD]
[TD]434545633
[/TD]
[TD] 5633 - 6456.99
[/TD]
[TD] 5,633.00
[/TD]
[TD] $ 70.00
[/TD]
[TD] $ 140.00
[/TD]
[TD] $ 14.00
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]EXPECTED RESULTS
[/TD]
[TD]PAYROLL DATE
[/TD]
[TD]MONTHLY SALARY
[/TD]
[TD]EMPLOYEE CONTRIBUTION
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]31-12-2018
[/TD]
[TD]6000.00
[/TD]
[TD]70.00
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]30-11-2018
[/TD]
[TD]6000.00
[/TD]
[TD]61.40
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Okay so at the moment if the salary fell into the class 9 category the old rate would apply until you update your table to the new rate for class 9

So we need to find the latest class by date that matches the salary bracket

That's correct.
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Before the rate increase I used to use this formula
VLOOKUP(I4,'NIS AND TAX TABLE'!$E$2:$F$18,2)
So if an employee's salary was 6000 he/she would fall in the Class 8 category. If their salary was 6457 but less than 7409.99 they would fall in the Class 9 category and those rates would be applied. Now that the rates have been increased, there are 2 Class 8 rates. The second Class 8 rate would come into effect on 20/12/2018 so everyone being paid after the 20/12/2018 and with a salary between 5633 and 6456.99 will now have to use the second Class 8 rates. The table is a set rate so you just have to lookup what salary range you fall in and at what date you are being paid and apply the rate.


Book1
ABCDEFGH
1DATECLASSKEYMONTHLY SALARY RANGEMONTHLY SALARYEMPLOYEE CONTRIBUTIONEMPLOYEER CONTRIBUTIONCLASS Z
29/3/2016142616867867 - 1472.99867$11.90$23.80$1.79
39/3/201624261614731473 - 1949.991,473.00$17.40$34.80$2.61
49/3/201634261619501950 - 2642.991,950.00$23.30$46.60$3.50
59/3/201644261626432643 - 3292.992,643.00$30.10$60.20$4.52
69/3/201654261632933293 - 4029.993,293.00$37.20$74.40$5.58
79/3/201664261640306030 - 4858.994,030.00$45.10$90.20$6.77
89/3/201674261648534853 - 5632.994,853.00$53.20$106.40$7.98
99/3/201684261656335633 - 6456.995,633.00$61.40$122.80$9.21
109/3/201694261664576457 - 7409.996,457.00$70.40$140.80$10.56
119/3/2016104261674107410 - 8276.997,410.00$79.60$159.20$11.94
129/3/2016114261682778277 - 9272.998,277.00$89.10$178.20$13.37
139/3/2016124261692739273 - 10312.999,273.00$99.40$198.80$14.91
149/3/201613426161031310313 - 11396.9910,313.00$110.20$220.40$16.53
159/3/201614426161139711397 - 12652.9911,397.00$122.10$244.20$18.32
169/3/201615426161265312653 - 13599.9912,653.00$133.30$266.60$20.00
179/3/201616426161360013600 and over13,600.00$138.10$276.20$20.72
1812/20/201884345456335633 - 6456.995,633.00$70.00$140.00$14.00
19
20EXPECTED RESULTSPAYROLL DATEMONTHLY SALARYEMPLOYEE CONTRIBUTION
2112/31/2018600070
2211/30/2018600061.4
Sheet1


Dates are set above in American date notation...

In E21 control+shift+enter, not just enter, and copy across:

=IF($D21>=MAX($A$2:$A$18),INDEX(IF($A$2:$A$18>=MAX($A$2:$A$18),$F$2:$F$18),MATCH($E21,IF($A$2:$A$18>=MAX($A$2:$A$18),$E$2:$E$18),1)),INDEX(IF($A$2:$A$18<MAX($A$2:$A$18),$F$2:$F$18),MATCH($E21,IF($A$2:$A$18<MAX($A$2:$A$18),$E$2:$E$18),1)))

Note. Rates at rate revisions are assumed to be in ascending order.
 
Upvote 0
=IF($D21>=MAX($A$2:$A$18),INDEX(IF($A$2:$A$18>=MAX($A$2:$A$18),$F$2:$F$18),MATCH($E21,IF($A$2:$A$18>=MAX($A$2:$A$18),$E$2:$E$18),1)),INDEX(IF($A$2:$A$18<max($a$2:$a$18),$f$2:$f$18),match($e21,if($a$2:$a$18<max($a$2:$a$18),$e$2:$e$18),1)))

Note. Rates at rate revisions are assumed to be in ascending order.

Thanks, but there seems to be a problem with the formula. Also I tried to enter a new rate in the table for example if there were three Class 8 (03/09/2016, 20/12/2018 and lets say 7/1/2019), won't using the MAX ignore the second set of rates? </max($a$2:$a$18),$f$2:$f$18),match($e21,if($a$2:$a$18<max($a$2:$a$18),$e$2:$e$18),1)))
 
Upvote 0
Thanks, but there seems to be a problem with the formula. Also I tried to enter a new rate in the table for example if there were three Class 8 (03/09/2016, 20/12/2018 and lets say 7/1/2019), won't using the MAX ignore the second set of rates? </max($a$2:$a$18),$f$2:$f$18),match($e21,if($a$2:$a$18<max($a$2:$a$18),$e$2:$e$18),1)))

Please do not comment on/discuss the formulas or explain your problems in terms of formulas which do not work or fit them. Just provide an appropriate input and an output that you expect for that input.
 
Upvote 0
Please do not comment on/discuss the formulas or explain your problems in terms of formulas which do not work or fit them. Just provide an appropriate input and an output that you expect for that input.

I did that in post #7
 
Upvote 0
{=INDEX(NIS[EMPLOYEE CONTRIBUTION],MATCH(MAX((NIS[MONTHLY SALARY]<=J13)*NIS[MONTHLY SALARY])*MAX((NIS[EFFECTIVE DATE]<=J14)*NIS[EFFECTIVE DATE]),NIS[MONTHLY SALARY]*NIS[EFFECTIVE DATE],0))}

This is the current formula I have. The problem with it is, if it doesn't have a matching date for the salary range it returns #N/A. So a salary of $6000 will give me the correct results but if i wanted the rate for $8000 after 12/20/2018 it returns #N/A
 
Upvote 0
1. If this is the formula I proposed, try to Convert the table to Range and repost the formula.


2. Try to complete "if i wanted the rate for $8000 after 12/20/2018 it returns #N/A" by also saying what value should be returned.


3. If [2] does not apply to the data of post #1 , provide the data where this result must obtain.
 
Upvote 0
=IF($D21>=MAX($A$2:$A$18),INDEX(IF($A$2:$A$18>=MAX($A$2:$A$18),$F$2:$F$18),MATCH($E21,IF($A$2:$A$18>=MAX($A$2:$A$18),$E$2:$E$18),1)),INDEX(IF($A$2:$A$18<max($a$2:$a$18),$f$2:$f$18),match($e21,if($a$2:$a$18<max($a$2:$a$18),$e$2:$e$18),1)))

Note. Rates at rate revisions are assumed to be in ascending order.

Your formula is incomplete. The last INDEX is followed by an IF with no values to return.

Using this formula:

{=INDEX(NIS[EMPLOYEE CONTRIBUTION],MATCH(MAX((NIS[MONTHLY SALARY]<=E21)*NIS[MONTHLY SALARY])*MAX((NIS[EFFECTIVE DATE]<=D21)*NIS[EFFECTIVE DATE]),NIS[MONTHLY SALARY]*NIS[EFFECTIVE DATE],0))}

D21 = 1/1/19
E21 = 6000
F21 = 70

but if

D21 = 1/12/18
E21 = 6000
F21 = 61.40

also if

D21 = 1/1/19
E21 = 10000
F21 = 99.40




</max($a$2:$a$18),$f$2:$f$18),match($e21,if($a$2:$a$18<max($a$2:$a$18),$e$2:$e$18),1)))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top