8 Replies Latest reply: Feb 13, 2015 10:21 AM by SaaiiKirran pabbuu

# Webi report (ForAll & Foreach)

Currently Being Moderated

hi,

Can anyone give me idea about ForAll & Foreach in Webi report (give me example plz in details).

Regards,

• ###### Re: Webi report (ForAll & Foreach)
Currently Being Moderated

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

block:

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

following block:

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.

Simply,

Input Context: ForEach

Output Context: ForAll

Above is reference from WEBI User guide.

Regards,

Vamsee

• ###### Re: Webi report (ForAll & Foreach)
Currently Being Moderated

one more thing what do u mean of Input & Output Context in Webi Report, Bcz i knw context in the term of Universe but in case of webi report don't have idea.

Regards,

• ###### Re: Webi report (ForAll & Foreach)
Currently Being Moderated

Thanks......................

• ###### Re: Webi report (ForAll & Foreach)
Currently Being Moderated

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:

http://www.dagira.com/2010/01/04/calculation-context-part-i-overview/

Your question has inspired me to finish the follow-up post for ForEach and ForAll, so I guess I will work on that next.

• ###### Re: Webi report (ForAll & Foreach)
Currently Being Moderated

Hi,

In universe Context is nothing but a path. Where as in Report level Context is about how to calculate the values using dimensions.

• ###### Re: Webi report (ForAll & Foreach)
Currently Being Moderated

Hi Vamsee Krishna,

Very well explained in detail..

• ###### Re: Webi report (ForAll & Foreach)
Currently Being Moderated

Does Filter Bar affect the results of the same if used in the conditional formatting?

• ###### Re: Webi report (ForAll & Foreach)
Currently Being Moderated

Hi,

You can get the idea about ForEach and Forall in the SAP Help