Restrict and Lookup

The functionality of the Restrict and Lookup formulas is very similar. They differ in the way the results are displayed, showing a breakdown of aggregated numbers.

Syntax

RESTRICT([<account member>], [<POV>])
LOOKUP([<account member>], [<POV>], [<Ignore Dimension>])
ACCOUNTLOOKUP([<measure name>],[<account member>])
MEASURELOOKUP([<account member>],[<measure name>])

Parameter

Usage

<account member>

Specifies an account member in the model.

<Point of View>

This is a list containing selected dimensions and their members:

[d/<dimension name>=<account member1>, <account member2>]

This is used to further restrict data in the account member (see following example 1).

Additionally, you can use time navigation syntax to identify specific periods (see example 2 and the following examples, and the dynamic time navigation functions below).

If dimension member values are strings, enclose them in quotation marks:

[d/Employee]="e1"

If the dimension has multiple values, group them in parentheses:

[d/Employee]=("e1","e2")

You can use multiple POV parameters and ignored dimensions by using the AND keyword. See example 3 below.

You can use dimension attributes or properties in the POV. See example 5 below.

<Ignore Dimension>

A dimension that will be ignored.

<measure name>

Specifies a measure in the model.

Example:

  1. RESTRICT([Income],[d/Employee]=("e1","e2"))

  2. RESTRICT([Sales],[d/Date]=Previous("Year", 1).Next("Day", 5))

  3. LOOKUP([Sales],[d/Employee]="Anne" and [d/Country]="Spain" and [d/Product]=("Paper","Glue"), [d/Country] and [d/Product])

  4. RESTRICT([SalesRevenue],[d/Products]!="Apple Juice")

  5. RESTRICT([NetRevenue],[d/ResponsibilityCenter].[p/currency]="CAD")

An extensive set of keywords is available for time navigation. The following examples show how these are used:

LOOKUP([Sales],[d/Date]=Next("Year",1).Current("Month"))
RESTRICT([Sales],[d/Date]=Next("Year",1).Last("Quarter",1).Last("Month",1))
LOOKUP([Sales],[d/Date]=Next("Year",1).LastPeriods("Month",2))

AccountLookup and MeasureLookup

These functions are only accessible from within the Modeler, both in the Model Structure and Calculations and workspaces. To avoid errors while running the functions, make sure to pass the arguments in the right order. Also, you can use Ctrl + Space to open the list of dimensions and measures you can when writing the function.

Dynamic Time Navigation Functions

These functions can be used only in the POV parameter of the Restrict and Lookup formulas. Use hints after the [d/Date] = string to access them in the formula bar, and select Set Dynamic Time Filter.

Except for the LastPeriods function, these functions can be combined using periods. Ensure that the Granularity order is correct.

Example: Previous("Year",4).First("Quarter",3).Last("Month",6))

Function

Syntax

Parameters

Meaning

Example (based on the date 2017.07.14)

ToPeriod

ToPeriod("Granularity")

(String Granularity)

Sums the (aggregated) values over a given period.

ToPeriod("Year") returns the sum of the values from the beginning of the year to the current date.

First

First("Quarter",3)

(String Granularity, Number N)

The Nth member relative to the parent granularity; for example, the Nth month of the quarter.

Not available for “Year” (because there is no parent).

First("Month",2).First("Day",1) refers to 2017.08.01.

This is the first day of the second month of the current quarter of the current year.

Note: if the default hierarchy is Year/Month/Day (that is, there is no Quarter level), then the above example would instead refer to 2017.02.01.

Last

Last("Month",6)

(String Granularity, Number N)

The Nth-last member relative to the parent granularity; for example, the Nth-last quarter of the year.

Not available for “Year” (because there is no parent).

Last("Quarter",2).First("Month",3).Current("Day") refers to 2017.09.14.

This is the current day of the third month of the 2nd-last quarter of the current year.

Previous

Previous("Quarter",2)

(String Granularity, Number N)

The Nth member before the current one.

Previous("Month", 1) refers to 2017.06.14.

Next

Next("Year",4)

(String Granularity, Number N)

The Nth member after the current one.

Next("Year", 3) refers to 2020.07.14.

Current

Current("Year")

(String Granularity)

The current member.

This is the default value.

Current("Day") refers to 2017.07.14.

LastPeriods

LastPeriods("Year",4)

(String Granularity, Number N)

Sums the (aggregated) values of the last N members of the given granularity (including the current one).

LastPeriods("Year",3) sums the aggregated values of 2017, 2016, and 2015.

How to Use Restrict and Lookup

In the case where an aggregated number is based on a dimension where some members in the hierarchy have been excluded by the filter, there will be gaps in the selected data. When you analyze such an aggregated number by drilling down to lower levels, how should these gaps be handled and what should be shown? These formulas provide two solutions:

  • Restrict – shows no value for rows or columns where no data has been selected.

  • Lookup – simply shows the aggregated value for all lines (including filtered out members).

Here are a number of examples that show how these two solutions can be implemented, first by comparing Restrict and Lookup, and then by showing how the additional IgnoreDimension parameter for Lookup can be used.

All the following examples are based on a simple dataset showing revenue for three products and two countries:

Product Country DE Country FR

Paper

1$

4$

Plastic

2$

8$

Glue

16$

32$

Restrict()

In this example, select two of the three products (paper and glue):

Example

RESTRICT([MyAccount],[d/Product]=("Paper","Glue"))

Total value returned: 53$. That is, an aggregated value for all paper and glue from all countries.

Further analysis: using Restrict, if you drill down further in the product dimension, any lines for products that were not selected will show empty cells:

Lookup()

Lookup can be used with exactly the same parameters for the same purpose. But the behavior for handling lower-level values is different. This example formula makes exactly the same selection as the previous Restrict example:

Example

LOOKUP([MyAccount],[d/Product]=("Paper","Glue"))

Total value returned: 53$. That is, an aggregated value for all paper and glue from all countries.

Further analysis: using Lookup, if you drill down further in the product dimension, Lookup will show a value for all lines:

  • All selected lines will show the same total value.

  • The same value is also used for all other products that have not been selected (in this example, Plastic).

Lookup Using the Ignore External Dimension Parameter

The next examples follow on from the previous scenario to show the behavior of Lookup using the additional parameter IgnoreDimension.

Example

In this first example, the same dimension filter for Paper and Glue is applied, and the IgnoreDimension parameter is used to disregard the country dimension:

LOOKUP([MyAccount],[d/Product]=("Paper","Glue"),[d/Country])

Total value returned = 53$. That is, values for all paper and glue from all countries (country is ignored).

Further analysis:

  • When drilling down to show product detail, no value is shown for products that have been filtered out (not been selected).

  • When drilling down to show country detail, the same accumulated value is shown for both countries.

Example

If the filter (POV) parameter is omitted from Lookup, then all products are selected:

LOOKUP([MyAccount],,[d/Country])

Total value returned = 63$. That is, values for all products from all countries.

Further analysis:

  • When drilling down to show product detail, all values are available (no filter was applied).

  • When drilling down to show country detail, the same accumulated value for all products is shown for both countries.