Hi. How can we help?

Logic functions

Lightspeed Analytics provides many functions that perform different mathematical, logical, and table-based calculations. You can find a more in-depth catalog of available functions on the Looker list of functions and operators page.

These functions are categorized in five different ways:

This article covers seven logic-based functions.

And

And is used to return a result if two or more sets of criteria are met.

In this example, the date of the sale was Monday and the category of sale was Bikes.

You need at least two sets of criteria defined as IF functions. In this case, the positive and negative responses must be yes and no:

table_calculations.png

The calculation looks like this:

if(${sales.time_stamp_day_of_week}="Monday",yes,no) AND if(${cl_category_tops.top_level_category}="BIKES",yes,no)

And if the calculation is saved properly, this is the result:

and_calculation.png

is_null

is_null returns whether a field is null. It requires one argument for the field it is searching:

For example, to find days with sales of products with no category:

is_null.png

The calculation looks like this:

is_null(${cl_category_tops.top_level_category})

After you save, here is the result:

is_null_calculation.png

No

No is not a defined function but it is a response to logical calculations (such as is_null), which can be used in compound calculations. 

In this example, Analytics finds instances of categories that are null. If they are not, Analytics returns a 1, and if they are, returns a 0:

no.png

The calculation looks like this:

if((is_null(${cl_category_tops.top_level_category}))=no,1,0)

If the calculation is properly saved here is the result:

no_report.png

Not

Not returns the inverse results of what is asked for in Yes or No results. 

To illustrate:

not_table_calculation.png

The calculation looks like this:

NOT if(${sales.time_stamp_day_of_week}="Sunday",yes,no)

If the calculation is done properly, here is the result:

not_report.png

Or

Like And, Or is used to return a result if at least one of two (or more) arguments is fulfilled. 

For example, in this calculation, you're looking for instances where the day of the sale was Monday, or the category of the sale was Bikes:

or_calculation.png

The calculation looks like this:

if(${sales.time_stamp_day_of_week}="Monday",yes,no) OR if(${cl_category_tops.top_level_category}="BIKES",yes,no)

If the calculation is done properly, here is the result:

or_report.png

Row

Row returns the number corresponding to the row on the table. No argument is required:

row_calculation.png

The calculation looks like this:

row()

If it is prepared properly, here is the result:

row_report.png

Yes

Like No, Yes is a response to logical calculations (such as is_null), which can be used in compound calculations.

In the converse example of No, search for instances where the product category is null:

yes_calculation.png

The calculation looks like this:

if((is_null(${cl_category_tops.top_level_category}))=yes,1,0)

If prepared properly, here is the result:

yes_report.png

Was this article helpful?

0 out of 0 found this helpful