Lookup multiple customers and apply their respective slabs

amandeep08

Board Regular
Joined
Mar 20, 2011
Messages
130
Office Version
  1. 365
Hi All,

I have 100+ customers and each one is having different commission slabs. I want the formula which will match the customer name and apply the respective slabs on the sales done by them.

I have tried multiple formulas but not able to get success. Apart from this, i have tried putting the slabs in a cell without equal sign and tried to ccalculate the same basis the lookup value but it also not worked. Pl help me
 
As stated, You can build your own factor for each set of common brackets and rates.

If you want to retain the slabs, you can review the following formula approaches and pick the alternative that you prefer.

Commissions 2024.xlsm
ABCDFGIJ
1
2Customer NameSalesCommissionCommissionCustomer NameStart SlabMargin
3
4B200,000.0016,400.00
5
6
7B06%6%
8B100007%1%
9B500008%1%
10B1000009%1%
11
1216,400.0016,400.0016,400.00
13
1f
Cell Formulas
RangeFormula
D4D4=B_Commission(B4)
J7:J10J7=I7-N(I6)
B12B12=LET(s, 200000,b,{0;10000;50000;100000},r,{0.06;0.01;0.01;0.01},SUM((s>b)*(s-b)*r))
D12D12=LET(s, 200000,b,{0;10000;50000;100000},r,{0.06;0.01;0.01;0.01},SUMPRODUCT(--(s>b),(s-b),r))
F12F12=SUMPRODUCT(--(B4>G7:G10),(B4-G7:G10),J7:J10)
Lambda Functions
NameFormula
B_Commission=LAMBDA(Sales,LET(s, Sales,b,{0;10000;50000;100000},r,{0.06;0.01;0.01;0.01},SUM((s>b)*(s-b)*r)))
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I am using Office 365.
Please add that to your forum profile (click your user name at the top right of the forum, then ‘Account details’) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
I wish I had seen this thread first...but I recently responded to an unanswered thread dealing with the same problem here:
...which is now closed. I see that Dave shares my concern about the gap of "1" between the end of one slab and the beginning of another, as the slab start array in his LAMBDA function is the same idea that I mentioned. I think that's a cleaner approach to close the gap between slabs. In any case, to the OP, my suggestion in the other thread offers a way to extract the slab details for each name, and then the computation method is essentially the same as what Dave describes above. My formula computes the same differential commission rates ("r" in post 9 above) and redefined start slab quantities ("b" in post 9), although it might be easier to implement than hardcoding those arrays in this case, because they change for every name. If you have any comments/questions about the other thread, just post here and I'll receive a notification.
 
Upvote 0
Please review the formulas and select the format that works best for you; Excel's Formulas Formula Evaluate may help.
I added arithmetic columns that also illustrate the calculations.
You can put the brackets and rate differentials and calculation in one row if that helps.
When you are comfortable with the formulas and the results, you may consider just using the formula like D3.

Commissions 2024.xlsm
ABCDEFGHIJKL
1NameSalesCommission v1Commission v2Commission v3NameBracketsRatesRate DifferentialArithmeticArithmetic
2A100,000.003,400.003,400.003,400.00A00.020.02200.002,000.00
3S200,000.0014,750.0014,750.0014,750.00A100000.030.011,200.00900.00
4A500000.040.012,000.00500.00
5A1250000.050.010.00
6A1E+308
7S00.060.063,000.0012,000.00
8S500000.070.013,500.001,500.00
9S1000000.080.016,000.001,000.00
10S1750000.090.012,250.00250.00
111E+308
12
1ff
Cell Formulas
RangeFormula
C2C2=SUM((B2>H2:H5)*(B2-H2:H5)*J2:J5)
D2D2=LET(b,{0;10000;50000;125000},rd,{0.02;0.01;0.01;0.01},SUM((B2>b)*(B2-b)*rd))
E2:E3E2=SUMIFS($L$2:$L$10,$G$2:$G$10,A2)
C3C3=SUM((B3>H7:H10)*(B3-H7:H10)*J7:J10)
D3D3=LET(b,{0;50000;100000;175000},rd,{0.06;0.01;0.01;0.01},SUM((B3>b)*(B3-b)*rd))
K2:K4K2=MAX(0,MIN($B$2-H2,H3-H2))*I2
J2:J5,J8:J10J2=I2-N(I1)
L2:L5L2=MAX(0,($B$2-H2)*J2)
H6,H11H6=BigNum
J7J7=I7
K7:K10K7=MAX(0,MIN($B$3-H7,H8-H7))*I7
L7:L10L7=MAX(0,($B$3-H7)*J7)


Commissions 2024.xlsm
ABCDEFGHIJKLM
1NameSalesCommission v1BracketsRate Differentials
2A100,000.003,400.000.0010,000.0050,000.00125,000.000.020.010.010.01
3S200,000.0014,750.000.0050,000.00100,000.00175,000.00
4B200,000.0016,400.000.0010,000.0050,000.00100,000.000.060.010.010.01
5
1fff
Cell Formulas
RangeFormula
C2C2=SUM((B2>F2:I2)*(B2-F2:I2)*J2:M2)
C3C3=SUM((B3>F3:I3)*(B3-F3:I3)*{0.06,0.01,0.01,0.01})
C4C4=LET(s, B4,b,F4:I4,r,J4:M4,SUM((s>b)*(s-b)*r))
 
Upvote 0
Commissions 2024.xlsm
ABD
1NameSalesCommission v2
2A100,000.003,400.00
3S200,000.0014,750.00
4
1ff
Cell Formulas
RangeFormula
D2D2=LET(b,{0;10000;50000;125000},rd,{0.02;0.01;0.01;0.01},SUM((B2>b)*(B2-b)*rd))
D3D3=LET(b,{0;50000;100000;175000},rd,{0.06;0.01;0.01;0.01},SUM((B3>b)*(B3-b)*rd))
 
Upvote 0
I adapted Kirk's suggestion.
1. I cleaned up the source data
2. I calculated the rate differential in the rate information range
3. I named the new Lambda formula in Name Manager; name the formula to a user-friendly name relevant for you.
4. The formula prompts for the rate information range, customer name (reference), and Sales amount (reference)

Commissions 2024.xlsm
ABCDEFGHI
1Customer NameSalesCommissionCommissionCustomer NameBracketsRatesRate Differential
2A100,000.003,400.003,400.00A02%2%
3S200,000.0014,750.0014,750.00A10,0003%1%
4A50,0004%1%
5A125,0005%1%
6S06%6%
7S50,0007%1%
8S100,0008%1%
9S175,0009%1%
10
1gg
Cell Formulas
RangeFormula
C2:C3C2=LET(rinfo,$F$2:$I$9,cslab,FILTER(rinfo,CHOOSECOLS(rinfo,1)=A2),b,CHOOSECOLS(cslab,2),r,CHOOSECOLS(cslab,4),SUM((B2>b)*(B2-b)*r))
D2:D3D2=Commissions_X(F2:I9,A2,B2)
Lambda Functions
NameFormula
Commissions_X=LAMBDA(rngRateData,customer,Sales,LET(rinfo,rngRateData,cn,customer,s,Sales,cslab,FILTER(rinfo,CHOOSECOLS(rinfo,1)=cn),b,CHOOSECOLS(cslab,2),r,CHOOSECOLS(cslab,4),SUM((s>b)*(s-b)*r)))
 
Upvote 0
Commissions 2024.xlsm
ABCDEFGHI
1Customer NameSalesCommissionCustomer NameBracketsRates
2A100,000.003,400.00A02%
3B200,000.0016,400.00A10,0003%
4S200,000.0014,750.00A50,0004%
5S300,000.0023,750.00A125,0005%
6A300,000.0013,150.00B06%
7B300,000.0025,400.00B10,0007%
8B50,0008%
9B100,0009%
10S06%
11S50,0007%
12S100,0008%
13S175,0009%
14
1g
Cell Formulas
RangeFormula
C2:C7C2=Comm_x($G$2:$I$13,A2,B2)
Lambda Functions
NameFormula
Comm_x=LAMBDA(rngRateData,customer,Sales,LET(rng,rngRateData,cn,customer,s,Sales,cslab,FILTER(rng,CHOOSECOLS(rng,1)=cn),b,CHOOSECOLS(cslab,2),r,CHOOSECOLS(cslab,3),ro,VSTACK(0,DROP(r,-1)),SUM((s>b)*(s-b)*(r-ro))))
 
Upvote 0
I wish I had seen this thread first...but I recently responded to an unanswered thread dealing with the same problem here:
...which is now closed. I see that Dave shares my concern about the gap of "1" between the end of one slab and the beginning of another, as the slab start array in his LAMBDA function is the same idea that I mentioned. I think that's a cleaner approach to close the gap between slabs. In any case, to the OP, my suggestion in the other thread offers a way to extract the slab details for each name, and then the computation method is essentially the same as what Dave describes above. My formula computes the same differential commission rates ("r" in post 9 above) and redefined start slab quantities ("b" in post 9), although it might be easier to implement than hardcoding those arrays in this case, because they change for every name. If you have any comments/questions about the other thread, just post here and I'll receive a notification.
Sir,

You have given the formula and it is working fine. Just wanted to check if i am inserting one column between G & H, how the formula will be changed. Pl help he as i am not able to understand your formula.
 
Upvote 0
In the version I posted, the slab lookup data are defined as variable "slab" located in the range $E$3:$H$10, It sounds as if the range will now be something like slab,$E$3:$G$10. Consider this to be a mini-table, so column E has a column index of 1, column F is 2, column G is 3, and column H is 4. The rest of formulas reference the columns like this.

Because each Customer Name might have different slab tiers and commission rates, we need to extract just the portion of the main "slab" table that applies to that particular customer. So "cslab" does this by applying a FILTER to "slab", and it requires CHOOSECOLS(slab,1)=A3, meaning that the Customer Name in "slab" column 1 (that's actually column E) matches the name in cell A3. In the example, cell A3 is customer A, and the resulting cslab lookup table will be:
A
0​
10000​
0.02​
A
10001​
50000​
0.03​
A
50001​
125000​
0.04​
A
125001​
0.05​

The 3rd column here (original column G labeled "End Slab") is used to create a new array for the "Start Slab" that begins at 0 and adopts all of the existing end slab tier values as the start slab values. This adjustment addresses a problem with the way the original slab tiers are defined. For example, if a lookup value of 10000.5 is given, the original table cannot place that value in any of the tiers because it exceeds the "end slab" value of 10000 of the first tier, but it is below the "start slab" threshold of 10001 for the second tier. What I've just described is performed in this step for variable "csslab"...Customer specific start slab...VSTACK(0,DROP(CHOOSECOLS(cslab,3),-1))
and it converts this End Slab...
10000​
50000​
125000​
to this new Start Slab...
0.00​
10000​
50000​
125000​
So if your End Slab remains in the 3rd column position, no change is necessary.

Similarly, the Commission column in "cslab" is assigned to the variable named "ccom" and is defined as CHOOSECOLS(cslab,4)...the 4th column. If Commission is now in the 5th column of E:I, the "4" should be changed to "5"...otherwise it remains as "4". Can you post a small example of what the new table structure looks like?
 
Upvote 0
In the version I posted, the slab lookup data are defined as variable "slab" located in the range $E$3:$H$10, It sounds as if the range will now be something like slab,$E$3:$G$10. Consider this to be a mini-table, so column E has a column index of 1, column F is 2, column G is 3, and column H is 4. The rest of formulas reference the columns like this.

Because each Customer Name might have different slab tiers and commission rates, we need to extract just the portion of the main "slab" table that applies to that particular customer. So "cslab" does this by applying a FILTER to "slab", and it requires CHOOSECOLS(slab,1)=A3, meaning that the Customer Name in "slab" column 1 (that's actually column E) matches the name in cell A3. In the example, cell A3 is customer A, and the resulting cslab lookup table will be:
A
0​
10000​
0.02​
A
10001​
50000​
0.03​
A
50001​
125000​
0.04​
A
125001​
0.05​

The 3rd column here (original column G labeled "End Slab") is used to create a new array for the "Start Slab" that begins at 0 and adopts all of the existing end slab tier values as the start slab values. This adjustment addresses a problem with the way the original slab tiers are defined. For example, if a lookup value of 10000.5 is given, the original table cannot place that value in any of the tiers because it exceeds the "end slab" value of 10000 of the first tier, but it is below the "start slab" threshold of 10001 for the second tier. What I've just described is performed in this step for variable "csslab"...Customer specific start slab...VSTACK(0,DROP(CHOOSECOLS(cslab,3),-1))
and it converts this End Slab...
10000​
50000​
125000​
to this new Start Slab...
0.00​
10000​
50000​
125000​
So if your End Slab remains in the 3rd column position, no change is necessary.

Similarly, the Commission column in "cslab" is assigned to the variable named "ccom" and is defined as CHOOSECOLS(cslab,4)...the 4th column. If Commission is now in the 5th column of E:I, the "4" should be changed to "5"...otherwise it remains as "4". Can you post a small example of what the new table structure looks like?

Hi,
I have new column (Marked Yellow) but not able to calculate the commission amount. Pl help

Book1
ABCDEFGHIJKL
1Customer NameCustomer Category Sales CommissionCustomer NameCustomer CategoryStart SlabEnd Slab% Margin
2AReseller8,25,000AReseller-5,00,0001.00%
3BCorporate12,25,000AReseller5,00,0007,50,0000.80%
4CEmployee7,35,000AReseller7,50,00010,00,0000.70%
5AReseller10,00,0000.60%
6BCorporate-10,00,0001.00%
7BCorporate10,00,00012,00,0000.85%
8CEmployee12,00,0000.75%
9CEmployee-2,00,0001.50%
10CEmployee2,00,0005,00,0001.25%
11CEmployee5,00,00010,00,0001.00%
12CEmployee10,00,0000.75%
Sheet1
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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