[Solved] Formula referencing formula

Discuss the spreadsheet application
Post Reply
jboush
Posts: 5
Joined: Tue May 25, 2021 8:14 pm

[Solved] Formula referencing formula

Post by jboush »

A1 and B1 contain formulae pulling numbers from elsewhere. C1 contains a formula: =if(A1>B1;A1;B1) and never pulls a number from either A1 or B1. What am I doing wrong?
Last edited by robleyd on Wed May 26, 2021 2:22 am, edited 1 time in total.
Reason: Tagged [Solved]; add green tick
Open Office 4.1.5 on Windows 10 Home
FJCC
Moderator
Posts: 9274
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Formula referencing formula

Post by FJCC »

It is hard to say without a file to look at. What does appear in C1?
Can you upload a file. To do that, click PostReply and look for the Upload Attachment tab just below the box where you type a response.
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.
jboush
Posts: 5
Joined: Tue May 25, 2021 8:14 pm

Re: Formula referencing formula

Post by jboush »

nothing appears
Attachments
problem sheet.ods
(7.77 KiB) Downloaded 88 times
Open Office 4.1.5 on Windows 10 Home
FJCC
Moderator
Posts: 9274
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Formula referencing formula

Post by FJCC »

The formula in C1 is behaving as expected. It is

Code: Select all

=IF(A1>B1;A1;B1)
A1 contains an empty string, "", because of its formula and B1 contains 2. If you test the condition of the IF function by writing

Code: Select all

= A1 > B1

in D1, you will see that it is TRUE. Therefore, the IF in C1 returns the content of A1, which is an empty string and the cell looks 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.
jboush
Posts: 5
Joined: Tue May 25, 2021 8:14 pm

Re: Formula referencing formula

Post by jboush »

so you're saying that the formula reads nothingness as greater than a numerical value

is there no way to alleviate the clutter that replacing "" with a bunch of zeros will cause (in the long run, that is. the sheet will be filled with these)
Open Office 4.1.5 on Windows 10 Home
FJCC
Moderator
Posts: 9274
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Formula referencing formula

Post by FJCC »

You are comparing a number to a character, so the sorting order is not what you expect. A formula cannot return nothing. The formula in A1 returns an empty string, which, though empty, is still a string. When sorting, numbers are smaller than any string, even an empty one. Try sorting column A in the attached file. Note that A3 and A7 contain numbers while all of the other cells in A2:A7 contain text with A5 containing the empty string and A6 containing the string "2". Sorting in ascending order places the numbers first, then the empty string, then the text 2, then A, then E.
Attachments
SortTest.ods
(8.41 KiB) Downloaded 73 times
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.
jboush
Posts: 5
Joined: Tue May 25, 2021 8:14 pm

Re: Formula referencing formula

Post by jboush »

ok, thank you
Open Office 4.1.5 on Windows 10 Home
User avatar
karolus
Volunteer
Posts: 1159
Joined: Sat Jul 02, 2011 9:47 am

Re: Formula referencing formula

Post by karolus »

why not simply =MAX(A1:B1)
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
jboush
Posts: 5
Joined: Tue May 25, 2021 8:14 pm

Re: Formula referencing formula

Post by jboush »

that also works, ty
Open Office 4.1.5 on Windows 10 Home
Post Reply