[Solved] Get value based on alternatives; IF function?

Discuss the spreadsheet application
Post Reply
Cruise105
Posts: 6
Joined: Sat Sep 01, 2018 4:20 pm

[Solved] Get value based on alternatives; IF function?

Post by Cruise105 »

Greetings,

Not sure if this is the right place for this, but here it goes ...
I am trying to get one cell to show a result based on what is in another cell.

Details:
Cell D2 will either have Intelligence, Wisdom, or Charisma shown.
I want Cell E2 to show one result if Intelligence is in D2, a different result if Wisdom is in D2, and yet a different result if Charisma is in D2.
I also want Cell F2 to show a different result than E2 based on the same argument.

How would I go about doing this. I know the IF function is what I need, I just don't know how to write it out.

Attached is a small file of what I have so far, and what I am trying to accomplish.
Attachments
OpenOffice Help.ods
(16 KiB) Downloaded 114 times
Last edited by MrProgrammer on Thu Apr 01, 2021 10:40 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved]
Apache OpenOffice 4.1.3
Windows 10 64Bit
User avatar
robleyd
Moderator
Posts: 5083
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: IF Function

Post by robleyd »

Something like this for E2:

Code: Select all

=If(D2="Intelligence";"one result";if(D2="Wisdom";"a different result";If(D2="Charisma";"yet a different result"; "??")))
If D2 contains none of the above, ?? is displayed

You could also use a lookup e.g. VLOOKUP..
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
MrProgrammer
Moderator
Posts: 4906
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Get value based on alternatives; IF function?

Post by MrProgrammer »

Cruise105 wrote:I know the IF function is what I need, I just don't know how to write it out.
Thank you for the attachment. IF() is the wrong function for this task. It might be acceptable for three alternatives, but it will be unsuitable for a few dozen. You need a better approach.
XY Problem
Cruise105 wrote:Cell D2 will either have Intelligence, Wisdom, or Charisma shown.
I want Cell E2 to show one result if Intelligence is in D2, a different result if Wisdom is in D2, and yet a different result if Charisma is in D2.
You want to perform table lookups. Depending on the situation use MATCH with INDEX, use VLOOKUP, or use HLOOKUP.
In E2: =INDEX($H$2:$J$2;MATCH(D2;$H$3:$J$3;0)).
In F2: =INDEX($L$2:$N$2;MATCH(D2;$L$3:$N$3;0)).
202103251341.ods
(12.54 KiB) Downloaded 100 times
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] VLOOKUP questions and answers
[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
Post Reply