[Solved] Creating if then formula with 2 choices

Discuss the spreadsheet application
Post Reply
carwena
Posts: 8
Joined: Thu May 10, 2012 10:24 pm

[Solved] Creating if then formula with 2 choices

Post by carwena »

I am trying to create an if then formula with 2 possible choices where one of the choices is a blank cell. This is what I have, which is not right but kind of describes what I'm trying to do. =IF(D4=30 THEN (E4=23) IF D4=90 THEN BLANK)
Last edited by carwena on Sat Feb 26, 2022 10:42 pm, edited 1 time in total.
apache open office 3.4 and Mac OS X version 10.7.3
User avatar
robleyd
Moderator
Posts: 5528
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Creating if then formula with 2 choices.

Post by robleyd »

Assuming this formula is to be in E4, what result do you want if D4 is neither 30 or 90?

If the formula is not to be in E4, please give a little more detail of exactly what you are trying to achieve. Note that a formula can only affect the cell in which it is located.
Slackware 15 (current) 64 bit
Apache OpenOffice.1.16
LibreOffice 26.8.0.3; SlackBuild for 26.8.0 by Eric Hameleers
-----------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
carwena
Posts: 8
Joined: Thu May 10, 2012 10:24 pm

Re: Creating if then formula with 2 choices.

Post by carwena »

Thanks for responding so quickly! I'm try to set up Rx reorder reminder sheet. Some Rx's have a 30 day supply while others a 90 day. I have included a sheet (prescription sample) trying to illustrate what I mean.
Attachments
prescriptions sample.ods
(22.56 KiB) Downloaded 109 times
apache open office 3.4 and Mac OS X version 10.7.3
User avatar
MrProgrammer
Moderator
Posts: 5474
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Creating if then formula with 2 choices.

Post by MrProgrammer »

carwena wrote: I'm try to set up Rx reorder reminder sheet. Some Rx's have a 30 day supply while others a 90 day.
Look in my attachment at the formulas in columns F and G. Rows 6 to 16 also contain the formulas but they are written to show nothing until data is entered in columns D and E.
202202260027.ods
Formulas for 30 days and 90 days
(14.8 KiB) Downloaded 128 times
carwena wrote:=IF(D4=30 THEN (E4=23) IF D4=90 THEN BLANK)
An IF function uses this syntax =IF(condition;result_when_true;result_when_false). All IF functions return a result whether the condition is true or false, so you will always want to supply the appropriate result_when_false value. The first tutorial below will help you with creating formulas which have multiple situations to be tested. You never use the keyword THEN in the function.

You do not want to use =TODAY() in column E because that formula is recalculated each time you open the document, so the dates in your spreadsheet would change in the future! Just type the current date in the cell and do not use a formuia in column E. A shortcut for a day in the current month, when you know the day of the month, is to type that followed by a slash. Thus in February to enter February 26 you would type 26/ and press Enter. On a Mac, the day of the month is always shown in the Dock.
Day of the month in the Dock
Day of the month in the Dock
If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the subject field. Select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know   ← You should read this, carwena
[Tutorial] Mac FAQ   ← Many Mac questions are answered here
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
robleyd
Moderator
Posts: 5528
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Creating if then formula with 2 choices.

Post by robleyd »

Given the layout you have, you don't seem to need a nested IF; just a simple IF for each of the two re-order periods. See F12:G13 in the attached file.
Attachments
prescriptions.ods
(16.88 KiB) Downloaded 109 times
Slackware 15 (current) 64 bit
Apache OpenOffice.1.16
LibreOffice 26.8.0.3; SlackBuild for 26.8.0 by Eric Hameleers
-----------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
carwena
Posts: 8
Joined: Thu May 10, 2012 10:24 pm

Re: Solved: Creating if then formula with 2 choices

Post by carwena »

Thank you for responding! I think it has to be nested because the reorder date is in 21 or 76 not 30 & 90.
apache open office 3.4 and Mac OS X version 10.7.3
Post Reply