Set analysis and set expressions
Set analysis offers a way of defining a set (or group) of data values that is different from the normal set defined by the current selections.
Normally, when you make a selection, aggregation functions, such as Sum, Max, Min, Avg, and Count aggregate over the selections that you have made: the current selections. Your selections automatically define the data set to aggregate over. With set analysis you can define a group that is independent of the current selections. This can be useful if you want to show a particular value, for example, the market share of a product across all regions, irrespective of the current selections.
Set analysis is also powerful when making different sorts of comparisons, such as what are the bestselling products compared with poorlyselling products, or this year against last year.
Let us imagine an example in which you start working in a document by selecting the year 2010 in a list box. The aggregations are then based on that selection, and the charts only show values for that year. When you make new selections, the charts are updated accordingly. The aggregations are made over the set of possible records defined by the current selections. With set analysis, you can define a set that is of interest to you and does not depend on the selections.
Creating set expressions
Before looking at the different parts of a set analysis example, there is a distinction that should be made between a set expression and set analysis:
Defining a set of field values is referred to as defining a set expression, whereas using set expressions to analyze data is referred to as set analysis. Consequently, the rest of this section focuses on the set expression and its components.
Here is a set analysis example: sum( {$<Year={2009}>} Sales ), in which {$<Year={2009}>} is a set expression.
There are two general syntax rules for a set expression:
 A set expression must be used in an aggregation function. In this example, the aggregation function is sum(Sales).
 A set expression must be enclosed by braces, {}. In the example, the set expression is: {$<Year={2009}>}.
A set expression consists of a combination of the following parts:
 Identifiers. One or more identifiers define the relationship between the set expression and what is being evaluated in the rest of the expression. A simple set expression consists of a single identifier, such as the dollar sign, {$}, which means all records in the current selection.
 Operators. If there is more than one identifier, an operator or operators are used to refine the set of data by specifying how the sets of data represented by the identifiers are combined to create a subset or superset, for example.
 Modifiers. A modifier or modifiers can be added to the set expression to change the selection. A modifier can be used on its own or to modify an identifier to filter the data set.
Examples:
Example 1:
This set expression contains an identifier
Example 2:
This set expression contains the identifiers $ and 1, the operator + and the modifiers <Year={2009}> and <Country={'Sweden'}>.
This set expression is designed to sum the sales for the year 2009 associated with the current selections and add the full set of data associated with the country Sweden across all years.
Identifiers, operators and modifiers are described in more detail with in the following subsections.
Identifiers
Identifiers define the relationship between the set expression and the field values or expression being evaluated.
In our example sum( {$<Year={2009}>} Sales ), the identifier is the dollar sign,
This table shows some common identifiers.
Identifier  Description 


Represents the full set of all the records in the application, irrespective of any selections made. 

Represents the records of the current selection. The set expression {$} is thus the equivalent to not stating a set expression. 

Represents the previous selection. 

Represents the next (forward) selection. 

You can use any bookmark ID or bookmark name. 

You can reference the selections made in an alternate state by its state name. 
This table shows some examples with different identifiers.
Example  Result 


Returns total sales for the document, disregarding selections but not the dimension. 

Returns the sales for the current selection, that is, the same as 

Returns the sales for the previous selection. 

Returns the sales for the bookmark named BM01. 
Operators
Operators are used to include, exclude, or intersect parts of or whole data sets. All operators use sets as operands and return a set as result.
This table shows operators that can be used in set expressions.
Operator  Description 


Union. This binary operation returns a set consisting of the records that belong to any of the two set operands. 

Exclusion. This binary operation returns a set of the records that belong to the first but not the other of the two set operands. Also, when used as a unary operator, it returns the complement set. 

Intersection. This binary operation returns a set consisting of the records that belong to both of the two set operands. 

Symmetric difference ( 
This table shows some examples with operators.
Examples  Results 


Returns sales for everything excluded by the selection. 

Returns sales for the intersection between the selection and bookmark 

Returns sales excluded by the selection and bookmark 

Returns sales for the year 2009 associated with the current selections and add the full set of data associated with the country Sweden across all years. 
Modifiers
Modifiers are used to make additions or changes to a selection. Such modifications can be written in the set expression. A modifier consists of one or several field names, each followed by one or several selections that can be made in the field. Modifiers begin and end with angle brackets, <>.
A set modifier modifies the selection of the preceding set identifier. If no set identifier is referenced, the current selection state is implicit.
This table shows some examples with modifiers.
Example  Result 


Returns the sales for the current selection where 

Returns the sales for region US, disregarding the current selection. 

Returns the sales for the selection, but with the selection in Region removed. 

Returns the same as the example above. When the set to modify is omitted, 

Returns the sales for the current selection, but with new selections both in Year and in Region. 
See: Set modifiers for a more detailed description of modifiers and how to use them in more complex set analysis.