AND Function
Description:
The AND function checks whether all arguments are TRUE, and returns TRUE if all arguments are TRUE.
Return Value:
AND returns a single boolean value depending on the combination of values that you test.
Syntax:
AND( <Logical1>,<Logical2> )
- Description of the parameters:
PARAMETER |
DESCRIPTION |
---|---|
Logical1 |
The logical values to test |
Logical2 |
The logical values to test |
Example:
As an example, we would like to create a measure that returns "Good" if the sales amount is greater than 100.000.000 and the quantity is greater than 400.000 otherwise Blank. We can achieve this using the following formula:
AND_Measure =
IF(
AND(SUM(Sales[SalesAmount])>100000000,SUM(Sales[SalesQuantity])>400000),
"Good",
BLANK()
)
The AND function accepts only two arguments. In case there are three or more conditions to evaluate use the operator '&&'. By adding a third condition to the previous formula, it now becomes:
Measure =
IF(
SUM(Sales[SalesAmount])>100000000
&& SUM(Sales[SalesQuantity])>400000
&& SUM(Sales[UnitPrice])>20000,
"Good",
BLANK()
)
OR Function
Description:
The OR function checks whether one of the arguments is TRUE to return TRUE. The function returns FALSE if both arguments are FALSE.
Return Value:
OR returns a single boolean value depending on the combination of values that you test.
Syntax:
OR( <Logical1>,<Logical2> )
- Description of the parameters:
PARAMETER |
DESCRIPTION |
---|---|
Logical1 |
The logical values to test |
Logical2 |
The logical values to test |
Example:
We will use the previous example, but this time we want to display "Good" if the sales amount is greater than 100.000.000 or the quantity is greater than 400.000 otherwise Blank. We can achieve this using the following formula:
AND_Measure =
IF(
OR(SUM(Sales[SalesAmount])>100000000,SUM(Sales[SalesQuantity])>400000),
"Good",
BLANK()
)
The OR function accepts only two arguments. In case there are three or more conditions to evaluate use the operator '||'. By adding a third condition to the previous formula, it now becomes:
Measure =
IF(
SUM(Sales[SalesAmount])>100000000
|| SUM(Sales[SalesQuantity])>400000
|| SUM(Sales[UnitPrice])>20000,
"Good",
BLANK()
)
Related Video: