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?
CodePudding user response:
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
CodePudding user response:
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)