1

Using Google Sheets.

I would like to change to use several conditions which results different values, and if nothing else did not match, then result other value.

In pseudo code:

A1 = 8
Set B1 If A1=1, then B1 result is 100,
If A1=4, then B1 result is 200,
If A1=6, then B1 result is 300,
If A1=10, then B1 result is 400,
Else B1 result is 0. 

What formula is the most simplest way to describe this?

3

Off the top of my head, this should do what you're looking for.

=IF(A1=1,100,IF(A1=4,200,IF(A1=6,300,IF(A1=10,400,0))))

Broken down into pseudo code:

IF 
  A1=1
THEN
  100
ELSE
  IF 
    A1=4
  THEN
    200
  ELSE
    IF
      A1=6
    THEN
      300
    ELSE
      IF
        A1=10
      THEN
        400
      ELSE
        0

To do it with IFS, this should do:

=IFS(A1=1, 100, A1=4, 200, A1=6, 300, A1=10, 400, true, 0)

SWITCH would be this:

=SWITCH(A1, 1, 100, 4, 200, 6, 300, 10, 400, 0)

Google Sheets functions:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.