[Solved] Multiple IF function in one cell

Discuss the spreadsheet application
Post Reply
User avatar
dojo97
Posts: 4
Joined: Sun Aug 18, 2019 5:12 am

[Solved] Multiple IF function in one cell

Post by dojo97 »

If have this IF statement

Code: Select all

=IF(AND(H6>R6;R6>S6;S6>U6);"Uptrend-Bluesky") =IF(AND(H6<R6;R6>S6;S6>U6);"Uptrend-Retrace") =IF(AND(R6<S6;S6>U6);"Reset") =IF(AND(R6>S6;S6<U6);"Reversal")
that only gives "TRUE" or "FALSE" answer. The answers I need to come out are "Uptrend-Bluesky", "Uptrend-Retrace", "Reset" and "Reversal"

Need help! :-)
Last edited by robleyd on Sun Aug 18, 2019 9:12 am, edited 2 times in total.
Reason: Tagged [Solved]
Apache OpenOffice 4.1.6
Windows 10
User avatar
robleyd
Moderator
Posts: 5082
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Multiple IF function in one cell

Post by robleyd »

Your syntax needs to be like this:

Code: Select all

=IF (F1=5;"this"; IF (F1=4;"that"; IF (f4=3;"other"); "default"))
without all the = before the second and subsequent IF functions.
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
dojo97
Posts: 4
Joined: Sun Aug 18, 2019 5:12 am

Re: Multiple IF function in one cell

Post by dojo97 »

I tried this . .

=IF (H6>R6;R6>S6;S6>U6;"Uptrend-Bluesky"; IF(H6<R6;R6>S6;S6>U6;"Uptrend-Retrace"; IF(R6<S6;S6>U6;"Reset";IF(R6>S6;S6<U6;"Reversal");"default")))

and it gives out Err504


When I added the "(AND" and ")"
=IF (AND(H6>R6;R6>S6;S6>U6);"Uptrend-Bluesky"; IF(AND(H6<R6;R6>S6;S6>U6);"Uptrend-Retrace"; IF(AND(R6<S6;S6>U6;"Reset"); IF(AND(R6>S6;S6<U6;"Reversal");"default"))))
--> result: #Value!
Apache OpenOffice 4.1.6
Windows 10
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Multiple IF function in one cell

Post by Zizi64 »

In this case you must put the nested IF into the position of the FALSE answer.
=IF(the first condition;result when TRUE;result when FALSE)

=IF(the first condition;result when TRUE;IF(the second condition;result when TRUE;result when FALSE))

...and so on.
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
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Multiple IF function in one cell

Post by Zizi64 »

Please upload your ODF type sample file here.
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
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Multiple IF function in one cell

Post by Zizi64 »

=IF (H6>R6;R6>S6;S6>U6;"Uptrend-Bluesky"; IF(H6<R6;R6>S6;S6>U6;"Uptrend-Retrace"; IF(R6<S6;S6>U6;"Reset";IF(R6>S6;S6<U6;"Reversal");"default")))
You missed the logical AND function from the multiple conditions.
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
dojo97
Posts: 4
Joined: Sun Aug 18, 2019 5:12 am

Re: Multiple IF function in one cell

Post by dojo97 »

Attaching my spreadsheet . . . .
Apache OpenOffice 4.1.6
Windows 10
User avatar
robleyd
Moderator
Posts: 5082
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Multiple IF function in one cell

Post by robleyd »

Code: Select all

=IF(AND(H6>R6;R6>S6;S6>U6);"Uptrend-Bluesky";
IF(AND(H6<R6;R6>S6;S6>U6);"Uptrend-Retrace";
IF(AND(R6<S6;S6>U6);"Reset";
IF(AND(R6>S6;S6<U6);"Reversal";
"default"))))
Doesn't give an error and shows default when all of H6, R6, S6 and U6 are empty. You can copy that as is - Calc will convert the formula to one line; just make sure there are no leading spaces when you paste if you use the SELECT ALL option on the code box.
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
dojo97
Posts: 4
Joined: Sun Aug 18, 2019 5:12 am

Re: (SOLVED) Multiple IF function in one cell

Post by dojo97 »

THANKS Bro!!! :D :) :super:

My head was spinning with these syntax . . . .
Apache OpenOffice 4.1.6
Windows 10
User avatar
robleyd
Moderator
Posts: 5082
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Multiple IF function in one cell

Post by robleyd »

Pro tip; break it down into small steps and do one step at a time, each step ensuring the syntax is correct. I find it easier sometimes to construct the formula, step by step, as multi-line text in a simple text editor then copy into Calc.
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