Jelmer405
Jelmer405

Reputation: 199

IF Function with multiple true values

Google Sheets has the following IF Function:

IF(logical_expression, value_if_true, value_if_false)

Is it possible to have multiple 'values_if_true' where the formula chooses one of those values randomly? If so, how?

example sheet

Upvotes: 0

Views: 467

Answers (2)

player0
player0

Reputation: 1

Is it possible to have multiple 'values_if_true'

yes and its called "nesting". example:

=IF(A2=1, IF(B2="apple", "x", "y"), "z") 

further, you may place another nested if-statement instead x, y or z

on your example it is not clear how you want to alternate between apple and pear - there are several options (random, predetermined, alternating)

Upvotes: 1

A.Steer
A.Steer

Reputation: 411

If you are wanting to select a random value from column B, C or D you can use the INDEX and RANDBETWEEN functions along with an IF

=IF(A1=1,INDEX(B1:D1,RANDBETWEEN(1,3)),"")

You would then just need to extend the formula to the bottom of your data

Upvotes: 2

Related Questions