#130 — Use Formulas to Handle Interval Association

#130 — Use Formulas to Handle Interval Association




Problem description & analysis:

Here below is a data table:

source table

Task: We want to calculate the price value in column B according to the quantity in column A, and the calculation should follow the rule: different quantity intervals correspond to different prices, as shown in the table below:

calculation rule



Solution:

Use SPL XLL and enter in cell B2:

=spl("=[15,13.75,13,12.5]([30,50,100,300,500].pseg@r(?1))",A2)
Enter fullscreen mode

Exit fullscreen mode

The result is as follows:

result one

Then drag B2 down to every relevant row:

final results

The idea of the calculation is to use the pseg function to calculate which interval the quantity value belongs to [30, 50, 100, 300, 500], and then take out the price of the corresponding interval from the price sequence [15, 13.75, 13, 12.5] and return.


Download esProc Desktop for FREE and revolutionize your Excel processes using SPL XLL!! 🚀✨⬇️

✨SPL download address: esProc Desktop FREE Download

✨Plugin Installation Method: SPL XLL Installation and Configuration

✨References to other rich Excel operation cases: Desktop and Excel Data Processing Cases

✨YouTube FREE courses: SPL Programming



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *