Expression builder-Multiple if conditions

HI Guys

I am trying to write this expression and having difficulty.

Can someone help?

If([Tank or Gauge Name]=“66018”,[Tank or Gauge Name]=“Sales Tank #1”,[Tank or Gauge Name]=“11955”,
[Tank or Gauge Name]=“25293,[Tank or Gauge Name]=“1230”,[Production, Bbls]-27,


or([Tank or Gauge Name]=“1231”,[Production, Bbls]-0,


or([Tank or Gauge Name]=“21469”,[Production, Bbls]-44,


or[Tank or Gauge Name]=“11978”,[Production, Bbls]-19,""))

 

I have multiple conditions to evaluate and furmulate based on that condition to calculate the value 

Solved Solved
0 6 170
2 ACCEPTED SOLUTIONS

I was able to work up a solution

Here it is

IFS(
([Tank or Gauge Name]= "66018"),[Production, Bbls]-27,
([Tank or Gauge Name]="Sales Tank #1"),[Production, Bbls]-27,
([Tank or Gauge Name]="11955",),[Production, Bbls]-27,
([Tank or Gauge Name]="25293",),[Production, Bbls]-27,
([Tank or Gauge Name]=“1230”),[Production, Bbls]-27,
([Tank or Gauge Name]=“1231”),[Production, Bbls]-0,
([Tank or Gauge Name]=“21469”),[Production, Bbls]-44,
([Tank or Gauge Name]=“11978”),[Production, Bbls]-19,TRUE,"",)

Thanks for everyone who helped!

View solution in original post

Some other ways to express it:

SWITCH(
  [Tank or Gauge Name],
  "66018", [Production, Bbls] - 27,
  "Sales Tank #1", [Production, Bbls] - 27,
  "11955", [Production, Bbls] - 27,
  "25293", [Production, Bbls] - 27,
  “1230”, [Production, Bbls] - 27,
  “1231”, [Production, Bbls] - 0,
  “21469”, [Production, Bbls] - 44,
  “11978”, [Production, Bbls] - 19,
  ""
)

Or:

IFS(
  IN(
    [Tank or Gauge Name],
    LIST(
      "66018",
      "Sales Tank #1",
      "11955",
      "25293",
      “1230”
    )
  ),
    [Production, Bbls] - 27,
  IN(
    [Tank or Gauge Name],
    LIST(“1231”)
  ),
    [Production, Bbls] - 0,
  IN(
    [Tank or Gauge Name],
    LIST(“21469”)
  ),
    [Production, Bbls] - 44,
  IN(
    [Tank or Gauge Name],
    LIST(“11978”)
  ),
    [Production, Bbls] - 19
)

View solution in original post

6 REPLIES 6

IF function receives three expressions. It seems that on your formula your using more then 3 options.

SEE: 

https://support.google.com/appsheet/answer/10108198?hl=en

Thank you, but I am not able to pharse the ifs() statement to simultaneously satisfy all the conditions and evaluate based on conditions.

I have 4 sets of condition to formulate 4 different outcomes

I don't know if i understand correctly but you should try to adapt the formula bellow:

IFS(

AND(condition 1, condition 2, condition 3, condition 4),

RESULT1,

AND(condition 5, condition 6, condition 7 condition 8),

RESULT2,

...

)

If this is not exactly what you looking for, please explaing what you're trying to do, maybe it'll clarify the solution!

Here is what I tried

IFS(

AND([Tank or Gauge Name]=“66018”,[Tank or Gauge Name]=“Sales Tank #1”,[Tank or Gauge Name]=“11955”,
[Tank or Gauge Name]=“25293,[Tank or Gauge Name]=“1230”),
[Production, Bbls]-27,

AND([Tank or Gauge Name]=“1231”),[Production, Bbls]-0,
AND([Tank or Gauge Name]=“21469”),[Production, Bbls]-44,
AND([Tank or Gauge Name]=“11978”),[Production, Bbls]-19

Says

xpression 'IFS( AND([Tank or Gauge Name]=“66018”,[Tank or Gauge Name]=“Sales Tank #1”,[Tank or Gauge Name]=“11955”, [Tank or Gauge Name]=“25293,[Tank or Gauge Name]=“1230”), [Production, Bbls]-27, AND([Tank or Gauge Name]=“1231”),[Production, Bbls]-0, AND([Tank or Gauge Name]=“21469”),[Production, Bbls]-44, AND([Tank or Gauge Name]=“11978”),[Production, Bbls]-0' was unable to be parsed: Number of opened and closed parentheses does not match.

I was able to work up a solution

Here it is

IFS(
([Tank or Gauge Name]= "66018"),[Production, Bbls]-27,
([Tank or Gauge Name]="Sales Tank #1"),[Production, Bbls]-27,
([Tank or Gauge Name]="11955",),[Production, Bbls]-27,
([Tank or Gauge Name]="25293",),[Production, Bbls]-27,
([Tank or Gauge Name]=“1230”),[Production, Bbls]-27,
([Tank or Gauge Name]=“1231”),[Production, Bbls]-0,
([Tank or Gauge Name]=“21469”),[Production, Bbls]-44,
([Tank or Gauge Name]=“11978”),[Production, Bbls]-19,TRUE,"",)

Thanks for everyone who helped!

Some other ways to express it:

SWITCH(
  [Tank or Gauge Name],
  "66018", [Production, Bbls] - 27,
  "Sales Tank #1", [Production, Bbls] - 27,
  "11955", [Production, Bbls] - 27,
  "25293", [Production, Bbls] - 27,
  “1230”, [Production, Bbls] - 27,
  “1231”, [Production, Bbls] - 0,
  “21469”, [Production, Bbls] - 44,
  “11978”, [Production, Bbls] - 19,
  ""
)

Or:

IFS(
  IN(
    [Tank or Gauge Name],
    LIST(
      "66018",
      "Sales Tank #1",
      "11955",
      "25293",
      “1230”
    )
  ),
    [Production, Bbls] - 27,
  IN(
    [Tank or Gauge Name],
    LIST(“1231”)
  ),
    [Production, Bbls] - 0,
  IN(
    [Tank or Gauge Name],
    LIST(“21469”)
  ),
    [Production, Bbls] - 44,
  IN(
    [Tank or Gauge Name],
    LIST(“11978”)
  ),
    [Production, Bbls] - 19
)
Top Labels in this Space