ForEach context operator
The ForEach operator adds dimensions to a context.
Example: Using ForEach to add dimensions to a context
The following table shows the maximum revenue for each Quarter in a
report which contains the Quarter dimension but does not include it in the
It is possible to create a formula for the Max Quarterly Revenue column
that does not include the ForEach operator:
Max ([Sales Revenue] In ([Year];[Quarter])) In ([Year])
Using the ForEach context operator, you can achieve the same result with
the following formula:
Max ([Sales Revenue] ForEach ([Quarter])) In ([Year])
Why? Because the Year dimension is the default input context in the block.
By using the ForEach operator, you add the Quarter dimension to the context,
giving an input context of ([Year];[Quarter]).
ForAll context operator
The ForAll context operator removes dimensions from a context.
Example: Using ForAll to remove dimensions from a context
You have a report showing Year, Quarter and Sales Revenue and you want
to add a column that shows the total revenue in each year, as shown in the
To total revenues by year the input context needs to be (Year); by default
it is (Year; Quarter). Therefore, you can remove Quarter from the input
context by specifying ForAll ([Quarter]) in the formula, which looks like this:
Sum([Sales Revenue] ForAll ([Quarter]))
Note that you can use the In operator to achieve the same thing; in this
case the formula is:
Sum([Sales Revenue] In ([Year]))
This version of the formula explicitly specifies Year as the context, rather
than removing Quarter to leave Year.
Input Context: ForEach
Output Context: ForAll
Above is reference from WEBI User guide.
Measures are projected on a Webi report, meaning they appear to "roll up" to a level determined by a list of dimensions. Input context is a way to set the set of dimensions used to roll up a measure before doing a calculation, and output context is a way to set the list of dimensions used after the calculation is done.
IN is used to provide a list of dimensions to be considered, and any other dimensions present in the block are ignored.
ForEach is used to add an extra dimension that might not be included in the block (which is valid only for input context).
ForAll is used to specifically exclude a dimension, as "all" values of that dimension are used.
I have a blog post with examples of IN on a report here:
Your question has inspired me to finish the follow-up post for ForEach and ForAll, so I guess I will work on that next.