6 Replies Latest reply: Jan 7, 2015 9:52 PM by Akshay Shenvi RSS

Webi report (ForAll & Foreach)

Manoj Mishra
Currently Being Moderated



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





  • Re: Webi report (ForAll & Foreach)
    Vamsee Krishna Mandlem
    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



    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.



    Input Context: ForEach

    Output Context: ForAll


    Above is reference from WEBI User guide.