MAX(IF) complicated formula check

Discuss the spreadsheet application
Post Reply
Sheen
Posts: 19
Joined: Mon Jul 24, 2017 10:22 am

MAX(IF) complicated formula check

Post by Sheen »

Is this formula correct?

{=MAX(IF(OR(INDIRECT(ADDRESS(D1;24)):X144<0;INDIRECT(ADDRESS(D1;24)):X144>=0);Y23:Y144;""))}

Let's say D1=23. Column X is the column no. 24, hence 24 in the ADDRESS function.
It should take the range of X23:X144, check if each value in this range is smaller than, equal to, or greater than 0. If so - it should find the maximum corresponding value in the range Y23:Y144.
The essence of the problem is that I want to be able to change the value in D1, e.g. to 50 and that should change the relevant range to X50:X144.
OpenOffice 3.1 Windows 7
FJCC
Moderator
Posts: 9277
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: MAX(IF) complicated formula check

Post by FJCC »

I am sorry that I don't understand what you are trying to do but I can point out that the parts of your formula that are like

Code: Select all

INDIRECT(ADDRESS(D1;24)):X144
need to be changed to

Code: Select all

INDIRECT(ADDRESS(D1;24) & ":X144")
It seems to me that your OR() will always be TRUE unless a cell contains an error. I tried a simplified version

Code: Select all

=OR(B6 < 0; B6 >= 0)
and it is TRUE if B6 contains a number or text or is blank.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
Posts: 9277
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: MAX(IF) complicated formula check

Post by FJCC »

A simpler way to return a variable cell range is with the OFFSET function

Code: Select all

=OFFSET(X1; D1 - 1;0; 145 - D1;1)
That means: Start at X1, go down D1 - 1 rows, go right zero columns, expand the range to be 145 - D1 rows tall, make the range 1 column wide.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Sheen
Posts: 19
Joined: Mon Jul 24, 2017 10:22 am

Re: MAX(IF) complicated formula check

Post by Sheen »

I was trying to write a condition for "if cell does not contain "" ". In other words, the condition should only be true if there is a number in the cell. What formula to use for that? Is "" treated as a blank cell?
OpenOffice 3.1 Windows 7
User avatar
robleyd
Moderator
Posts: 5085
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: MAX(IF) complicated formula check

Post by robleyd »

This may help; from the offline help (F1)
ISBLANK
Returns TRUE if the reference to a cell is blank. This function is used to determine if the content of a cell is empty. A cell with a formula inside is not empty.
If an error occurs, the function returns a logical or numerical value.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: MAX(IF) complicated formula check

Post by Villeroy »

Functions like Min, Max, Average, Sum, Count etc. ignore empty cells, empty strings and all kinds of text, even if the text represents a number. A blank cell, text "abc" or text "99" does not affect the result.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Sheen
Posts: 19
Joined: Mon Jul 24, 2017 10:22 am

Re: MAX(IF) complicated formula check

Post by Sheen »

I am stuck.
I have got:

SUMIF(X8:X144;">0")

D1 = 21
Then it may change to D1=23

All I want is X8 in the range to change to X21, or X23, or X(whatever_number_is_in_D1).

I am frustrated as no solutions suggested work. I get only errors. Please help.
OpenOffice 3.1 Windows 7
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: MAX(IF) complicated formula check

Post by Lupp »

Code: Select all

=SUMIF(OFFSET($X$8;$D$21-8;0;144-$D$21+1;1);">0")
or
=SUMIF(INDIRECT("X" & $D$21 & ":X144");">0")
The function you finally apply to the range is not of actual meaning in the context.
This thread is about how to get cell ranges (always rectangular!) depending on variable values.

OFFSET produces a reference to a cell range of five parameters of which the first one is a reference itself giving the cell to which the row offset and the column offset refer, and the following four are numbers. Read the help for more detail.

INDIRECT creates the reference from the address passed to it which is a text ('String'). There is no sorcery! You need to compose the string exactly as if you typed it directly. ADDRESS can help you to get the addresses of pole cells. The range operator ":" must be inserted by concatenation. You can also concatenate the range address completely from whatever parts you want - under the condition, of course, that the syntax is correct, and that you regard the meaning you intend.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply