[]
        
(Showing Draft Content)

Logical Functions

The logical functions return information about values in an expression. For example, the TRUE function helps you to determine whether an expression that you are evaluating returns a TRUE value.


Following is the list of logical functions supported in Wyn Enterprise:

AND


Description


The AND function checks whether both arguments are TRUE, and returns TRUE if both arguments are TRUE. Otherwise returns false. Checks whether both arguments are TRUE, and returns TRUE if both arguments are TRUE. Otherwise returns FALSE.


Syntax

AND(<logical1>,<logical2>) 

Parameters

Parameter

Description

logical1

The logical values you want to test.

logical2

The logical values you want to test.

Return Value


Returns TRUE or FALSE depending on the combination of values that you test.


Example

AND('Sale'[SaleAmount]>100,'Product'[Name]="Wyn")

Remarks

The AND function in WAX accepts only two (2) arguments. If you need to perform an AND operation on multiple expressions, you can create a series of calculations or, better, use the AND operator (&&) to join all of them in a simpler expression. For example :


AND('Sale'[SaleAmount]>100,'Product'[Name]="Wyn" && 'Category'[CategoryID]=1 ) or AND(AND('Sale'[SaleAmount]>100,'Product'[Name]="Wyn") ,'Category'[CategoryID]=1 )

IF


Description


The IF function checks a condition and returns one value when it's TRUE, otherwise, it returns a second value.


Syntax

IF(<logical_test>, <value_if_true>[, <value_if_false>])

Parameters

Parameter

Description

logical_test

Any value or expression that can be evaluated to TRUE or FALSE.

value_if_true

The value that's returned if the logical test is TRUE.

value_if_false (optional)

The value that's returned if the logical test is FALSE. If omitted, BLANK is returned.

Return Value


Either value_if_true, value_if_false, or NULL.


Example

IF('Sale'[Amount]>100, "High","Low")

The above example returns "High" if the Amount is greater than 100, otherwise returns "Low".

NOT


Description


The NOT function changes FALSE to TRUE, or TRUE to FALSE.


Syntax

NOT(<logical>)

Parameters

Parameter

Description

logical

A value or expression that can be evaluated to TRUE or FALSE.

Return Value


TRUE or FALSE.


Example

NOT('Sale'[Amount] > 109)

The above example will return FALSE if the Amount is greater than 109, otherwise, it will return TRUE.

OR


Description


The OR function checks whether one of the arguments is TRUE to return TRUE. The function returns FALSE if both arguments are FALSE.


Syntax

OR(<logical1>,<logical2>)

Parameters

Parameter

Description

logical1

The logical values you want to test.

logical2

A constant value to be matched with each row.

Return Value


A boolean value. The value is TRUE if any of the two arguments is TRUE; the value is FALSE if both the arguments are FALSE.


Example

OR('Sale'[Amount]> 10,'Category'[Key]>1)

The above example returns TRUE if the value of the Amount column of the Sale table > 10 or the Key column of the Category table is greater than 1. Otherwise returns FALSE.


Remarks

The OR function in WAX accepts only two (2) arguments. If you need to perform an OR operation on multiple expressions, you can create a series of calculations or, better yet, use the OR operator (||) to join them all in a simpler expression.

SWITCH


Description


The SWITCH evaluates an expression against a list of values and returns one of the multiple possible result expressions.


Syntax

SWITCH(<expression>, <value>, <result>[, <value>, <result>]…[, <else>])

Parameters

Parameter

Description

expression

Any expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context).

value

A constant value to be matched with the results of the expression.

result

Any scalar expression to be evaluated if the results of expression match the corresponding value.

else

Any scalar expression to be evaluated if the result of expression doesn't match any of the value arguments.

Return Value


A scalar value that comes from one of the result expressions, if there was a match with value, or from the else expression, if there was no match with any value.


Example 1

SWITCH([Month], 1, "January", 2, "February", 3, "March", 4, "April", 5, "May", 6, "June", 7, "July", 8, "August", 9, "September", 10, "October", 11, "November", 12, "December", "Unknown month number" ) 

In the above example, if the value is 1, it returns "January", if it is 2, it returns "February", and if it is 3, it returns "March"...


Example 2

SWITCH(TRUE,'Sale'[Amount] < 100 ,"less",'Sale'[Amount]=100,"equal100","greater")

In the above example, in the Sale table with a value of the Amount column less than 100, it will return "less", if the Amount column is equal to 100, it will return "equal100", and it will return "greater" if neither is satisfied.


Remarks

All result expressions and the else expression must be of the same data type.

IN


Description


The IN function checks if a set of parameters are contained within an Expression or scalar. It returns TRUE, if the value is equal to at least one value in the list, else it will return FALSE.


The multi-value parameters will be concatenated with "," in its values:

Type Values

Format

Values in WAX

Int, Float, Bool

[1,2,3,4.1, true]

1,2,3,4.1, true

String

["red", "blue", "orange"]

"red", "blue", "orange"

Date, DateTime

[2022-10-16, 2022-10-17]

"2022-10-16", "2022-10-17"

Syntax

 In(ColumnName, Value1, Value2, ...)      

Parameters

Parameter

Description

ColumnName

The column for which you want to compare the values.

Value

The parameter value that you will compare.

Return Value


TRUE or FALSE


Example

CALCULATE (
IN ('RetailDataset'[Order method type],"E-mail", "Fax","Web","Telephone" ) && 'RetailDataset'[Product type]=("Sunscreen")
)

The above function will return the values as "True" where the Order method types are "E-mail, Fax, Web, and Telephone" and the Product type is "Sunscreen". Otherwise, it will return "False".


Remarks

  • IN function supports using multi-values parameters in the WAX.

  • If the multi-values parameter has no default value, it will be formatted as an empty string, the WAX might fail in this case.

  • The multi-values parameter only can be used in the IN\NotIN function and the WAX editor will validate the usage of the parameters.

  • The parameter can be a URL parameter, user and organization context, the calculated table, it can come from the slicer, etc.

NotIn


Description


The NotIn function checks if a set of parameters are contained within an Expression or scalar. It returns TRUE, if the value is not in the list, else it will return FALSE.


The multi-value parameters will be concatenated with "," in its values:

Type Values

Format

Values in WAX

Int, Float, Bool

[1,2,3,4.1, true]

1,2,3,4.1, true

String

["red", "blue", "orange"]

"red", "blue", "orange"

Date, DateTime

[2022-10-16, 2022-10-17]

"2022-10-16", "2022-10-17"

Syntax

NotIn(ColumnName, Value1, Value2, ...)      

Parameters

Parameter

Description

ColumnName

The column for which you want to compare the values.

Value

The parameter value that you will compare.

Return Value


TRUE or FALSE


Example

CALCULATE (
NotIn('RetailDataset'[Order method type],"E-mail", "Fax","Web","Telephone" ) && 'RetailDataset'[Product type]=("Sunscreen")
)

The above function will return the values as "True" where the Order method type is not "E-mail, Fax, Web, and Telephone" and the Product type is "Sunscreen". Otherwise, it will return "False".


Remarks

  • NotIn function supports using multi-values parameters in the WAX.

  • If the multi-values parameter has no default value, it will be formatted as an empty string, the WAX might fail in this case.

  • The multi-values parameter only can be used in the IN\NotIN function and the WAX editor will validate the usage of the parameters.

  • The parameter can be a URL parameter, user and organization context, the calculated table, can come from the slicer, etc.