How to split cell value into multiple bands using array formula?

nkasic

New Member
Joined
Aug 11, 2015
Messages
15
I have price list i.e. discounts based on length in meters, and it looks like this:
Length more than metersDiscount (%)
0​
15%​
4​
55%​
8​
71,53%​
16​
55%​
32​
0%​

It's defined in pricelist and it't the same for each service.
However, discounts are applied in a way that first 4m discount is 15%. For the length after 4m, but before 8m discount is 55% etc.
That means, e.g. if I have length of 11,5m, there will be discount on price per meter of 15% for 4m (from 0 to 4m), discount of 55% for 4m (from 4m to 8m) and discount of 71,53% for 3,5m (from 8m to 11,5m).
For that purpose I need to split length into bands i.e. to determine length in each band in order to apply appropriate discount.
That is not a problem if I have just a single value as I can use a helper table and various standard formulas (IF, MAX etc9
However, this is part of large specification where there are a number of such items, so I need to develop formula which will result in an array of values, each representing length in each band.
E.g. if I have lenght of 57,731 I need a formula that will result in an array:


4​
4​
8​
16​
25,731​

i.e. resulting array should be: 4;4;8;16;25,731. That's how length of 57,731m is divided into bands according to the first table, and I already created array formulas that can use that array and multiply it with array of discounts and apply them and generate final, single value (price).
Simplified, my specification looks like this:
length (m)Serviceprice per meter (€)discount (%)Total price
11,5Service 11500,461178261
57,731Service 2300,300053697320331
123,123Service 166,7xxx
456,456Service 328,5xxx
12,13Service 413,4xxx
15,123Service 1121,55xxx
22,333Service 335,4xxxx

There are hundreds of rows, so I cannot use helper table for each row, but I need an array formula that I will use for calculating compound discount and final result (Total price) in each row.
Any idea?
Couldn't find anything similar on internet.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
This is basically like a tiered commission formula, and there are many such questions here - here is one example:

 
Upvote 0
If you are using excel 365, how about?:

Book2.xlsx
ABCDEFG
1length (m)Serviceprice per meter (€)discount (%)Total priceExpected result
211,5Service 1150,000,4611782610,461178261
357,731Service 230,000,3000536970,300053697
4123,123Service 166,700,140691828
5456,456Service 328,500,03794977
612,13Service 413,400,474376669
715,123Service 1121,550,522057918
822,333Service 335,400,537569964
Sheet2
Cell Formulas
RangeFormula
D2:D8D2=LET( l, A2, dl, {4;8;16;32}, d, {0.15;0.55;0.7153;0.55;0}, hdl, dl-VSTACK(0, DROP(dl,-1)), lgd, (l>=dl)*1, fd, SUM(IFERROR(lgd*hdl*d,0)), pd, INDEX(d,SUM(lgd)+1)*(l-INDEX(dl,SUM(lgd))), (fd + pd)/l )
 
Upvote 0
If you are using excel 365, how about?:

Book2.xlsx
ABCDEFG
1length (m)Serviceprice per meter (€)discount (%)Total priceExpected result
211,5Service 1150,000,4611782610,461178261
357,731Service 230,000,3000536970,300053697
4123,123Service 166,700,140691828
5456,456Service 328,500,03794977
612,13Service 413,400,474376669
715,123Service 1121,550,522057918
822,333Service 335,400,537569964
Sheet2
Cell Formulas
RangeFormula
D2:D8D2=LET( l, A2, dl, {4;8;16;32}, d, {0.15;0.55;0.7153;0.55;0}, hdl, dl-VSTACK(0, DROP(dl,-1)), lgd, (l>=dl)*1, fd, SUM(IFERROR(lgd*hdl*d,0)), pd, INDEX(d,SUM(lgd)+1)*(l-INDEX(dl,SUM(lgd))), (fd + pd)/l )
Thanks. The results are correct. I just have to figure out what your megaformula does :)
 
Upvote 0
Microsoft 365 Apps for enterprise

I suggest that you update your Account details (or click your user name at the top right of the forum) 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
Thanks. The results are correct. I just have to figure out what your megaformula does :)
Thanks for the feedback. Happy to help.

I just realized that the formula wouldn't work for lenght shorter than 4 m. Here is the corrected one:

Book2.xlsx
ABCDE
1length (m)Serviceprice per meter (€)discount (%)Total price
211,5Service 1150,000,461178261
357,731Service 230,000,300053697
4123,123Service 166,700,140691828
5456,456Service 328,500,03794977
612,13Service 413,400,474376669
715,123Service 1121,550,522057918
83Service 335,400,15
Sheet2
Cell Formulas
RangeFormula
D2:D8D2=LET( l, A2, dl, {4;8;16;32}, d, {0.15;0.55;0.7153;0.55;0}, hdl, dl-VSTACK(0, DROP(dl,-1)), lgd, (l>=dl)*1, fd, SUM(IFERROR(lgd*hdl*d,0)), pd, INDEX(d,SUM(lgd)+1)*(l-INDEX(dl,SUM(lgd))), IF(l>=4, (fd + pd)/l, TAKE(d, 1)) )
 
Upvote 0
I must say first time I see a discount calculation so complex. Just for my curiosity can you share what your company is selling?
As a client i would try to make purchases of 32 m each to have the maximum discount.
If you graph discount vs meters sold:
1724083306229.png
 
Upvote 0
This is basically like a tiered commission formula, and there are many such questions here - here is one example:

Yes, but the difference is, as I stated, that I have large sheet and I need to calculate this for each row, so I cannot use helper tables. I have Office 365 for Enterprise, so it supports array formulas natively, and most of the suggestions are based on earlier versions of Office. It should be easier to accomplish it with new functions.
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,081
Members
453,021
Latest member
Justyna P

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