# Replace max value [closed]

H \H*strong text How do I (for example) compare the numerical value of a1 to the numerical value of a2 and if a1 is greater than a2, replace a2 by a1? Every time I try to set up the IF formula, I get an error. I suppose this is recursive. So why can't I do recursive?

A1 changes periodically and can go up or down. I want to capture the max value of A1 in A2 whenever A1 exceeds A2.

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Alex Kemp close date 2015-10-21 15:25:02.368132

A1 changes periodically and can go up or down. I want to capture the max value of A1 in A2 whenever A1 exceeds A2. This is a circular reference problem rather than a recursive problem.

( 2013-02-08 05:25:29 +0200 )edit

Sort by » oldest newest most voted

A formula like:
=MAX(A1:B1)
works as expected if you have set up Iterations in Calc options.

more

Thanks, this works. gfc

( 2013-02-09 23:58:54 +0200 )edit

A1 changes periodically and can go up or down. I want to capture the max value of A1 in A2 whenever A1 exceeds A2.

made me thinking and I can imagine 3 situations:

(As you compare a1 and a2, I assume you have your figures in row 1 and row 2)

1. You want to compare the values in row 1 with a single value in row 2.
2. You want to detect the maximum value of row 1 for each period during which the values increase, decreases, increases....
3. You have a 2 rows of figures and you want to replace the values in row 2 with the values of row 1 whenever the the values in in cell of row 1 is greater than the value of the cell being just below of the figures, you want to replace the figure in row 2 with the figure of row 1.

If 1, then the answer by qubit is perfectly fine and in row 2 you will find the answer

If 2, the situation is a bit more complex and I would need to see you figures to get an idea what could be done.

If 3, you can apply the logic of qubit and have your formula in row 3

more

A1 changes periodically and can go up or down. I want to capture the max value of A1 in A2 whenever A1 exceeds A2.

more

What is A2? A fixed value or the first maximum detected? This is still not clear to me.

( 2013-02-12 04:56:47 +0200 )edit

This isn't a recursive problem.

1. If A1 <= A2, then nothing changes. Things only get interesting when A1 is strictly greater than A2.

2. If A1 > A2, then you set A2 = A1. At this point, A1 == A2, so you're back to case #1.

Could you provide an example of a situation in which you'd want to set up a spreadsheet this way?

more