Largest If?

Discuss the spreadsheet application
Post Reply
Robindude
Posts: 10
Joined: Sun Oct 06, 2013 11:43 pm

Largest If?

Post by Robindude »

I have a data set which has two columns of interest for this issue, which we'll call A and R (since they aren't adjacent in the listing right now).
Column A contains numbers or "N/A" if the field is invalid (based on other data, why it's that way isn't important).
Column R contains "Y" or "N" to designate a condition about the item represented by the row it's on.

What I need:

1) The largest number in column A but only counting those lines where the corresponding R column is "Y".
2) The largest number in column A but only counting those lines where the corresponding R column is "N".
(The above two are separate things.)

So if you had:
A R
5 Y
2 Y
3 N
4 N
1 Y
4 N

Request 1 returns 5, request 2 returns 4 (because 4 is the largest number where R is also "N", so even though the first row has a 5 in it, R is "Y" so it isn't counted).
Any ideas?
Open Office 4.0 on Win 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Largest If?

Post by Villeroy »

=MAX(IF(R1:R6="Y";A1:A6;"")) entered as array formula with Ctrl+Shift+Enter
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
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Largest If?

Post by Zizi64 »

It is achievable with the MAXIFS() function.
The MAXIFS() function exists in the LibreOffice Calc, but not exist in the AOO Calc.


One more approach: you can write a macro function for this task.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
robleyd
Moderator
Posts: 5082
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Largest If?

Post by robleyd »

Note: the formulae below are array formula and need to be entered in the input line, then press Ctrl-Shift-Enter - they will then appear enclosed in {} curly braces. Assuming values in A1 to A6 and conditions in R1 to R6.

For Y:

Code: Select all

=MAX(IF(R1:R6="Y";A1:A6))
and for N

Code: Select all

=MAX(IF(R1:R6="N";A1:A6))
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
Post Reply