Forum Discussion
Excel IF Formula
- Sep 08, 2020
ash_m200 Actually, similar questions have come up here twice the past week, though applied in different contexts.
https://techcommunity.microsoft.com/t5/excel/band-billing/m-p/1632141#M73901
Attached is the same type of solution that I provided then. I've adapted it to your specific situation. I trust you can apply the method demonstrated into your own file. If not, come back here.
Thank you - that did work, apologies for not finding the other posts
ash_m200 No apologies needed. Not easy to find these threads where one calls it "banded billing" and another "Help with a formula". You yourself called it "Excel IF Formula". And all of you were looking for some kind of tiered fee calculation. Glad I could help.
- PeterBartholomew1Sep 08, 2020Silver Contributor
Why not
= SUMIFS(RateDiff, Lower, "<="&Qty)
You appear to be catering for very old versions of Excel.
- Riny_van_EekelenSep 08, 2020Platinum Contributor
PeterBartholomew1 True, sometimes I'm still a bit into the old way of doing things. A habit I'm trying to get over, though.
But in this case, I believe your formula doesn't give the right answer as the rate should be tiered. For instance, a quantity of 500000 should return a rate of 0.04% i.e. (100000 x 0% + 400000 x 0.05%)/ 500000.
Your formula picks-up the rate that is valid as from 500000. But perhaps I'm mistaken.
- PeterBartholomew1Sep 08, 2020Silver Contributor
For the record, I did finally manage to process an array of amounts with a single array formula spilling to provide the results but it is not for the faint-hearted!
= LET( BandedAmounts, DIFF( IF(amount<cap, amount, cap ), amount*0,,,,0), Payment, SUMROWS( BandedAmounts * rates ), Payment )
It requires transposing the table of bounds and rates and using Charles Williams's FastExcel functions DIFF and SUMROWS to overcome Excels limitations in dealing with 2D arrays.
I would also observe that the solution looks nothing like a normal spreadsheet formula.