Showing posts with label Selection Steps. Show all posts
Showing posts with label Selection Steps. Show all posts

Saturday, January 17, 2015

OBIEE- Understanding Selection Steps logic and forcing it to be based on Measures

In this post I will give a reason to use selection steps, explain that Selection Steps logic is base on dimension, or actually, non-measure columns and will describe a way of forcing the Selection Step logic to work on measure values.

I assume you understand the basics of Selection Steps or read the post OBIEE 11g Hierarchical Columns and Selection Steps or something similar.

I will describe the same example described in the post "OBIEE- Understanding Selection Steps logic and forcing them to be based on Measures".

 It's a simple analysis:
With columns: Year, Product_Type and Revenue... The only not totally trivial part is the % of year calculation that is 100*Revenue / (Sum Revenue by Year)   (the formal code is 100*"Base Facts"."Revenue"/sum("Base Facts"."Revenue" by "Time"."Per Name Year")).

This how the result looks like, with totals by Year:

The request was to see the above 4 columns combination, only for Product Type greater than 150,000, but to maintain the correct "% of Year".   

The naive approach would be to add filter Revenue >150,000
But in this case the "% of Year" is totally wrong, since it's based only on the selected data:

 


------------------------------------------------------ a remark --------------------------------------------------
Actually OBIEE is very smart and on a slightly different problem (% of Year > some percentage) is doing great with filters, since in that case, we are doing the filter on the problematic column:


------------------------------------------------------ a remark -------------------------------------------------- 

The natural solution is to use selection steps, since they are executed after the initial select statement. 

But here we have a slight problem. Selection steps are not defined on measures, actually they are defined on non-measure columns. Why do I care? 

Because the naive approach would be to try the following selection step:
Per Product Type, keep only Revenue>150,000.

But the result is not as desired (I color-coded red all the "less than 150,000" cases):

 What happened?
 To understand, lets see the initial analysis with Years excluded:
The result of the Selection Step was to remove "Maintenance" and "Install" Product Type, with no consideration of the Year column. Why? Because of the nature of Selection Steps, it's applying measure values on a specific non-measure / dimension column. The only exception of this rule is the "For" option covered here, but it doesn't help in our case.
How can I solve this problem?
I will create a new dummy column that combines Year and Product Type, hide it, and use the same Selection Step.
(I'm lucky since I don't have to cast year to character, it's character by default):
The formula:

The Selection Step:

Hiding the dummy column:

The result (as desired):
You have more than 2 non-measure columns? Concatenate them all.
Summary:
1. Selection Steps in OBIEE are done on non-measure / dimension columns, using measure values.
2. To force / trick the Selection Step to work on measures values directly, we have to create a dummy column that combines all the non-measure keys, and is used as index of measure values in the analysis.  

 


Friday, January 9, 2015

OBIEE - What the "For" in Selection Steps stands for

As you probably remember, in OBIEE 11 there is a powerful option of selection steps, that enables us to add conditions that are executed after the filter / where condition of the analysis.
I covered the issue few times:
While creating a condition with Selection Steps, there is a "For" hiding in the center of the Selection Step Wizard:


 After pressing the plus sign, the following is visible:

A question was asked, what is it used for?

I got a little scared seeing the documentation:
 
For:
"Use this area to qualify all of the dimensions of the analysis other than the dimension whose members you want to select, when creating condition steps of type Exception or Top/Bottom. For each dimension, you select which of its members to include. You can select specific members, or All, which specifies to aggregate the members when creating the condition. For example, suppose that you are qualifying the Region dimension. You can select a specific region, such as East, whose value is used in the condition. If you select All, then the values of all regions are aggregated and used in the condition.
You can use the For area to create a qualified data reference (QDR). A QDR is a qualifier that limits one or more of the dimensions to retrieve a single value for a measure column. A QDR is useful when you want to temporarily reference a measure column value without affecting the current status of the dimensions. The following is an example of a QDR:
Add members of Total Products (Rgd Sk Lvl) where "A - Sample Sales"."Base Facts"."1- Revenue", For: Cust Segments Hier: 'Active Singles', 'Baby Boomers' is greater than "A - Sample Sales"."Base Facts"."1- Revenue", For: Cust Segments"
When you specify a QDR, you can specify multiple members for limiting the dimensions. When you specify multiple members, the measure column value is aggregated using the default aggregation from the Oracle BI Server. For example, suppose that you want to create a condition for displaying those Regions in which Units is greater than 100. Suppose that you create a QDR for the Year dimension that specifies 2000 and 2001 and that the default aggregation is Sum. If the values for 2000 and 2001 for the Central region are 50 and 60 respectively, then both those years are displayed, because their sum exceeds the 100 units that was indicated."

I'll do an example that I hope would make it easier to understand.

I created a simple Analysis:

Year, Product_Type and Revenue (Aggregation Rule - Sum)... The only not totally trivial part is the % of year calculation that is 100*Revenue / (Sum Revenue by Year)   (100*"Base Facts"."Revenue"/sum("Base Facts"."Revenue" by "Time"."Per Name Year")). i will use that column in the next post.

Using regular Filters I can limit the data only to those Product Types that have Revenue greater that 200,000.

But I have a slightly different need: I want to limit the data to the Product Type with Revenue  greater that 200,000 at the Year 2009. Of course I could do it with 2 analysis (using filter "based on results of another analysis"), but it's so easy to do with the For option of selection steps!
The original Analysis was (I color coded the Revenue>200,000):
With 2 values over 200,000 at year 2008, 4 at 2009 and 3 at 2010.

In selection step for Product Type I'll keep only Revenue greater that 200,000 ,

But that's not enough, I need it only for the Year 2009. That is where the "For" option kicks in. 

 Now the result is as requested:

I can see only the Product Types with Revenue over 200,000 in the year 2009.

To summarize it to myself:
By default Selection Step work on specific dimension column, "For" option uses the condition with additional dimension / dimensions.
If I would have selected 2 years, for example, 2009 and 2010, I would have limit the results to (Revenue of 2009) + (Revenue of 2010), greater that 200,000.
The default of "For All" takes all the Years Revenue (for each Product Type) and combines it.
So Keeping Product Types with Revenue >200,000 with no "For" definitions will summarize all values for each Product Type and make sure they are greater than 200,000.
More about it, in the next post.  



As you might have noticed, the manual selection of Year=2009 and of 200,000 as minimal Revenue, can be replaced by Prompt.

Tuesday, July 8, 2014

OBIEE - Comparing performance to peers

I was asked about an analysis where I compare the list of top 10 products of a company ( or sales person or anything else) with the top 10 off all the others. The idea is to see the top products of peers in compare to me.
I will describe here the solution I was asked about and in the next post some of my ideas how this could be done (better?).
(Done on OBIEE 11.1.1.7.140527).

Option 1

I'll use Sample Sales and compare Rank of Revenue by all companies with Rank of Revenue of specific company.
The Analysis:
The basic columns: Company, Product, Revenue
 Calculations:

Sum(Revenue by Product) = the total Revenue for each Product
Rank (Sum(Revenue by Product)) = The Ranking of each Product Revenue for the entire data
Rank(Revenue by Company) = The Ranking of each Product Revenue for each Company

Now I was requested to mark the cases where Rank(Revenue by Company) is not in top 10 while it is in top 10 in Rank (Sum(Revenue by Product)). This way I can see the products I can improve with.

So I created a column with the following cumbersome case statement:
case 
when rank(sum(Revenue by Product))<11 and rank(Revenue by Company)<11 THEN 'OK'  when rank(sum(Revenue by Product))<11 and rank(Revenue by Company)>10   then 'XXX' Else '' end
And used Conditional format so this column will be red when it's value is XXX.

The result is (I left the Original Column Header on purpose):

 We can add filter to the Analysis, to see only top 10 rank(sum(Revenue by Product)).

The result will be OK:

Now, I was told, it's very nice but we want to filter the company with dashboard prompt, so each Company will get it's own results by default.
THIS is a problem.
If we try a regular filter, we will loose the data of the other companies, and see only the selected one. 

What can we do?
Use selection steps!
Why? Because Selection steps are executed only after the general Query. 

Select the Company in List:

Edit "Stat with all members" 

Change the Action to "Start with all members" and mark "Override with prompt".

Now when we call the analysis from a dashboard, it is all working fine:


Option 2


Noy Dekel from Vision.BI remarked that this could be achieved with the Filter Function an presentation variable, as well:

This time we don't have the Company column:
We have only:
  • Product 
  • Revenue (we don't need the sum(revenue by Product since there is no company column)
  • FILTER("Revenue" USING ("Company" = '@{PV_COMP}{Genmind Corp}' )) 
  • RANK(Revenue)
  • Rank(FILTER("Revenue" USING ("Company" = '@{PV_COMP}{Genmind Corp}' )) )
  • The relevant case statement
Since the filter formula is Presentation Variable based, we can change it using a Prompt.




There is one small difference between the results: the second option always forces us to select by default a specific company, while the first allows us to see all values by default.


You are welcome to continue to OBIEE - Comparing performance to peers - next step


Sunday, March 24, 2013

OBIEE - Top 2 of top 10 with Selection Steps

In the past I talked about Hierarchical Columns and selection steps. 

Lets talk about additional sample of using Selection Steps. This time I don't use Hierarchical Column, just to show, we don't need to.

What I want is a report of Top 2 Offices with top 10 Products.
Lets start with a simple report of Department, Product and Revenue.

The result isn't exactly what I wanted, since the same products are sold by different  Departments.  
I want top 10 unique Products.
So lets create a column that gives a unique sum for each product ( SUM(Revenue by Product) ) and run the in Top 10 on it.
Now we have a list of 92 row, since they are 10 Departments.
Now I want the top 2 departments by its revenue from the 10 top products.
I could create another column and filter on it, but it's easier to use Selection Steps:

Lets concentrate on Offices - Department, and create a new condition.
 
Select the Top.. based on... condition
And select the "Keep Only", "is top", 2.

We can select the Measure (Revenue for our needs)
And run it for all members of the Products.

As a result we have the top 2 Departments that sell the top 10 Products:

You don't believe me?
Lets remove the Selection Step, and summarize by Department:
The result proves to be correct. Q.E.D.

Tuesday, March 12, 2013

OBIEE 11g Hierarchical Columns and Selection Steps

So we know what are Hierarchical Columns. What are Selection Steps?
Many people don't notice they exist is OBIEE 11g:
So what can we do with Selection Steps?
First of all they are not specific for Hierarchical Column.  Selection steps just like filter are intended to allow you to limit the data to fit your specific needs.
In the Users Guide, Chapter 5  there is a discussion about the difference between filters and Selection Steps.
  • Filters are applied before Selection Steps
  • Selection Steps are applied in the order you defined them
  • Selection Steps are applied after the query was aggregated and affects only the members displayed and not the resulting aggregates.
  • You can save Selection Steps for reuse.
  • Unlike filters, if you exclude or delete a dimension from you analysis, the Selection Steps are excluded/deleted as well (despite all my efforts).
In Selection Steps you can:
 Select Members, Add Group of Calculated Items, Apply a Condition and Select Members based on Hierarchy.
There are 3 types of action you usually do with them:
  • Keep - keep only the selected members
  • Add  - add the selected members to the result
  • Remove - remove the members from a result
We can have a long discussion about each option. We might do it one day, but lets have an example.
I want to create a set of previous 35 days based on time hierarchy. (I can do it with filters as well... The actual case was a bit more complicated).

So I can select"Apply a Condition in Time Hierarchy.
Now Select Condition type of "Last 3 Month":
In my case I want to keep only 
the last 35 values of day level 
in the Time Hierarchy.
I also want to override the value of 35 with a Presentation Variable, whenever I want. 



As a result the Time hierarchy values are now in Day level.


This is very "OLAP like" behavior. Selected Month level, would cause the report to show values of month and not dates.


I can now remove some of the days from the list as well, for example the last 32 days. So I'm left with only 3 days (it also fits very nicely with the not perfect data of the Sample).

Next I can save the Selection Steps for future use.
You can only save steps for a specific dimension.







So I'll save the steps in a selected folder.
In the screen:
The Name is the name of the members file.
Display Label is what you see in the Analysis (if I leave it empty, the name will be used).

The important question is what to Save: general steps, so it will give dynamic results, or just the members of the Results.

In our case the difference is between selecting each time the 3 days, or using the specific 3 days of this result, each time.

Now each time I create a new analysis, I can use saved Selection Steps:

I can even Edit the Start with all members
Then select a group of Calculated Item. That would be our Steps.

The result is:
(Please notice the little menu option near the Move arrow. You can select there "add" or "add members". The later will show you the days and not the "35 days" group you see in the result).

Another option is to add our Steps to existing "start with all" (or any other start with...)
This is what you get: