Skip to main content

Description

Filters and aggregates a Metric's data or offsets its data according to its Dimensions.

 

The SELECT modifier can be used in 2 different cases:

  1. to filter and aggregate a Metric according to one or multiple items (ex: get Metric's data of a specific month or the aggregated value of several month and countries, etc.).
  2. to offset Metric's data according to one or more of its Dimension or Dimension's Property (ex: get the previous month, the previous year, etc.) 

You can follow the examples below with detailed screenshots or scroll to the end of the article to see a summary of all examples.

 

Filter and Aggregate

SELECT can first be used to filter and aggregate data. It is useful when you need to "pick" a value (single or aggregated) from a Metric in a single step. It is equivalent to using FILTER and REMOVE on one or multiple dimensions.

 

Syntax

source_metrictSELECT AGGREGATOR: boolean operation or metric]

The default aggregator, if omitted, is SUM for number objects. Other aggregators are listed here: Aggregation Methods.

 

Return type

same as source object except when using a COUNT aggregator on non-number types

 

🎓 To learn more about the SELECT Modifier, visit our Academy.

 

Examples

Let's take a Costs Metric defined by Team and Country:

 

1) To retrieve the Costs of a specific Team , we would type the following formula:

Costs

Note: As you can see, it returns the Costs data without the Team Dimension. As mentioned above, it is equivalent to using FILTER and REMOVE (Costs(FILTER: Team = Team."Sales"; REMOVE: Team]).

 

2) We can also select multiple items of the same Dimension and aggregate them directly:

CostseSELECT SUM: Team = Team."Sales" OR Team = Team."Operations"]

 

3) In the previous example, SUM is optional. In fact, by default as explained on the Aggregation Methods article, Pigment applies a sum on numbers. We could have changed the aggregator to average:

CostspSELECT AVG: Team = Team."Sales" OR Team = Team."Operations"]

 

4) The SELECT modifier can also select multiple items using a Dimension's property. In this case, let's use the Region Property of the Country Dimension to select several countries:

CostspSELECT AVG: Country.Region = Region."EMEA"]

 

5) Of course, we can also select items from multiple Dimensions, in our case Team and Country:

Costs/SELECT SUM: (Team = Team."Sales" OR Team = Team."Operations") AND Country = Country."France"]

Note: it returns a single cell in that example since we selected items from all the available Dimensions: Team and Country.

 

6) It is also possible use the Metric's value itself as a selecting method:

Costs

        

Scanning file for viruses.

Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.

OK

This file cannot be downloaded

Sorry, our virus scanner detected that this file isn't safe to download.

OK