Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Hi All,

In this blog post Getting to know about the Context Operators (IN, ForEach and ForAll). First let me explain on this; IN, ForEach and ForAll these three operators are called Context operators. Do you know, why today i would like to share my knowledge about this topic because context operators mostly used in webi report.

Even you know by using (IN, ForEach and ForAll) operators; you just like Kill Two words with one stone, in other words to solve two problems at one time with a single action.

Have you ever noticed that IN, ForEach and ForAll these three webi functions like poweful keywords which most/ mostly serachable in Google search engine. Also in this blog post i covered all aspects about context operators; when any why required at the time of creating webi report.

I explain on these three operators below using an example:


In context operator - when / why we use?


For to me using In context operator to specifies dimensions explicitly in a context.


Example:- you have a report showing Year and Sales Revenue, but our requiremnent is to add one more column which showing maximum revenue by quarter. also you have the Quarter object in query panel but you do not include this dimension in the report block. Instead, you want to include an additional column to show the maximum revenue by quarter in each year.


Solution:- By Using the In context operator, you can achieve the Max Quarterly Revenue using below formula.


Max ([Sales Revenue] In ([Year];[Quarter])) In ([Year])


Finally Your report looks like this:

ForEach context operator - when and why we use?


For to me using the ForEach operator to add dimensions to a context.


Example:- How To show the maximum revenue for each Quarter in a report which having the Quarter dimension in query panel but does not include it in the block:


Solution:- Using the ForEach context operator, you can achieve the same result with using below formula:


Max ([Sales Revenue] ForEach ([Quarter])) In ([Year])


How does work/ Above formula explanation:- You know Year dimension is the default input context in the block. So, by using the ForEach operator, you add the Quarter dimension to the context, by giving an input context of ([Year];[Quarter]).


Finally Your report looks like this:

ForAll context operator - when and why we use?

For to me using the ForAll context operator to remove dimensions from a context.

Example:- You have a report showing Year, Quarter and Sales Revenue and you want to add a column that shows the Yearly total revenue.

Solution:- Using the ForAll context operator, you can achieve the same result with using below formula:

Sum([Sales Revenue] ForAll ([Quarter]))

How does work/ Above formula explanation:- By default you have input context (Year; Quarter), for total revenue by year the input context needs to be (Year); Therefore, you can remove Quarter from the input context by specifying ForAll ([Quarter]) in the formula, which looks like above.

Note:- You can also achieve the same result by using the the In operator; in this case the formula is below:

Sum([Sales Revenue] In ([Year]))

Finally Your report looks like this:

I hope you enjoyed lots and learned something new while reading this document.

Cheers,

Amrendra

7 Comments
Labels in this area