Was this page helpful?
Yes No
Have a comment? Please leave it here.Thanks for your feedback!

Home > 

Reference > Functions, Operators, & Data Types > Functions > Logical Functions

Logical Functions

Use cases

Use logical functions to create specific views from a data source without changing the source itself. For example, combine different members of a dimension, or filter a segment out of a view. Below are a few basic examples, using the IF statement with different types of logical operator. For more information about logical operators, see Operators.

Learn how to use logical functions to group members of a field, compare values, exclude values, and create virtual bins:

Group members of a field

In an OR statement, only one of the conditions in the statement needs to be true for the entire calculation to evaluate to true.

In this example, an OR operator is used to create a new region called East Coast, made up of members of the East and South regions:

IF [Region] = “East” OR [Region] = “South” THEN “East Coast” ELSE [Region] END

Using this calculation, your view will update to look like this:

Compare values

Logical statements that use the AND operator are useful when more than one field needs to be involved. In an AND statement, all conditions must evaluate to true for the overall calculation to be true.

The following calculation finds furniture sales for the Central region:

IF [Region] = “Central” AND [Product Category] = “Furniture” THEN [Sales] END

Use this calculation in a view to easily show how furniture sales in the Central region compare to total sales.

Exclude values

The calculation in this example uses the not equal to operator (<>). This operator is often used to exclude values or filter a member of a dimension out of a view.

The following formula calculates the total sales for all regions except East:

IF Region <> “East” THEN [Sales] END

Using this calculation, your view will update to look like this:

Create virtual bins

The greater than or equal to operator (>=) can be used to create virtual bins to categorize data in different ways. This type of calculation is very useful and is similar to how KPIs (Key Performance Indicators) are evaluated. In this calculation, the >= operator is used to group sales into large, medium, and small orders based on the dollar amount.

IF [Sales] >= 5000 THEN “Large Order”

ELSEIF [Sales] >= 1000 THEN “Medium Order”

ELSE “Small Order” END

Using this calculation, your view will update to look like this: