Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index

At 14:36 19/10/2013 +0200, Hylton Conacher wrote:
The initial formula is:

In addition I have tried changing the formula without success to try and reduce the multiple nested IF functions:

The SUMIF function was also tried but my brain just gave up. I cannot see how the VLOOKUP function will help either as I am not looking up values from cells, I am calculating a single value in H4 based in a variable input in G4. Have a peek at the uploaded spreadsheet on Nabble:

You can do what you need using VLOOKUP(), seeking values from a small table (much as you already have in rows 58 to 61). And you can probably more easily use MATCH(), which works fairly similarly, but returns a pointer instead of a value. But both of these methods suffer from the problem that you need to seek multiple values from your table in each calculation, so the formulae become rather cumbersome, with a necessity to retrieve essentially the same information repeatedly.

It's worth saying that it's generally not a good idea to repeat similar information - as you have at lines 21 to 32. Instead, either use values from a minimal table (as already mentioned) or embed the values in the formulae.

Let's redraw your table more simply - say in rows 71 to 74 of columns A and B:
150     1.25
350     1.25
600     1.52
(Nothing is needed in A71.)

Then you can calculate what you need using something like:
where G4 is your sample data cell.

Each line of this formula (I've split it only for ease of reading, of course) calculates the contribution to the cost from one of the four price bands. Each MIN() function ensures that the upper limit of the quantity is either the value itself or the upper limit of the band - whichever is smaller. So where are the IFs to test which bands are needed?, you ask. Well, each unnecessary contribution would be calculated here (wrongly) as negative, so the MAX() functions, with their first arguments of zero, cancel these incorrect contributions. Try it: it gives the answers you want.

I trust this helps.

Brian Barker

To unsubscribe e-mail to:
Posting guidelines + more:
List archive:
All messages sent to this list will be publicly archived and cannot be deleted


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.