View Single Post
  #41   Report Post  
Posted to free.uk.diy.home,uk.d-i-y
Nick Nick is offline
external usenet poster
 
Posts: 11
Default Spreadsheet help

Stuart Noble wrote:
Nick wrote:
Martin wrote:
"Stuart Noble" wrote in message
om...
if KWh is above 670 then C23-670 multipy by C29, but if below 670,
then answer should be 0 (zero)

Google for "open office if statements".

It's probably

=IF(c31670;(c23-670)*c29;0)

if I've got the cell numbers right. There's probably a more elegant
way ....

Not sure if it's any more elegant, but having used MIN for the first
670, the_constructor could use =MAX(0;(c23-670)*c29). And I don't
see any advantage in not combining the two elements in one cell, per
my original post.



I think you are right and I have, to a certain extent, programmed
spreadsheets professionally.

Max and Min are not so much "more elegant" but I would say "more
easily understandable".

Hope that makes you feel better ;o)


Well, the OP's original question was expressed in IF terms and, to a
beginner, this seems like a logical extension of the way we think.
"What do you want to see in cell A10?"
"Er, that depends. If this, then that, but, if not, then something else"
I got by quite nicely with IFs until they got so long and full of
brackets I was forced to learn a bit more.


Taking two arguments MIN or MAX are simpler than the three arguments of
an IF. MIN and MAX are also very basic mathematical functions taught to
all kids in school.

It is instructive to see that in this real life example the use of the
additional complexity of the IF statement introduces an error.

if should be
=IF(c23670;(c23-670)*c29;0)
instead of
=IF(c31670;(c23-670)*c29;0).

Finally as a matter of preference I would actually write

=MAX(0;c23-670)*c29

As to my mind this more closely models what is actually going on