Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
Daniel Gorman edited this page Nov 29, 2018 · 7 revisions

The AND Function

Function Group: Logical

AND returns true if the provided arguments all return logical true, otherwise it returns false. Everything except FALSE is treated as true.

Syntax

AND(arg1, [arg2...])

  • arg1 is an expression that can be interpreted as true or false (including numbers, strings, and arrays etc.)
  • arg2 is optional, and has the same restrictions as arg1
  • AND can take an arbitrary number of additional arguments as well

Uses

Let's say we're given a response with some fleet deployment information that looks like this:

{  
   "company_a":{  
      "deployments":{  
         "fleet_1":true,
         "fleet_2":true,
         "fleet_3":true
      }
   }
}

And another set of deployment information from an api that returns 1 as true, and where there was no data returned for the fleet_2 element:

{  
   "company_b":{  
      "deployments":{  
         "fleet_1":1,
         "fleet_2":null
      }
   }
}

If we want to determine that all deployments are completed, we can use AND:

AND(company_a.deployments.fleet_1, company_a.deployments.fleet_2, company_a.deployments.fleet_3)

This will return true.

Other Examples

We can also interpolate different kinds of "truthy" results.

AND(company_a.deployments.fleet_1, company_b.deployments.fleet_1) => true

AND(company_a.deployments.fleet_1, company_b.deployments.fleet_2) => false

Clone this wiki locally