Wednesday, January 30, 2013

Direct Database Requests


Direct Database Request allows one to run SQL statements directly on to a data source. The BI Server sends across user entered physical SQL statements directly to the connected data source.

Log on to Answers. You should have the privilege to perform a Direct Database Request.

To check whether you have privileges, go to Administration-> Security ->Manage Privileges.



If you are part of the group mentioned here, you have privileges to execute Direct Database Requests.

Now, let’s start creating one!

Click New -> Analysis -> Create Direct Database Request


Once here, mention the connection pool you want to use as mentioned in the rpd. 


Once this task is completed, write down the sql query you wish to execute in the SQL Statement tab.



As can be seen, the SQL query is written as you would write at the back end.. However, if we need to use this report in a dashboard which requires prompts to be applied to it, we need to create presentation variables.  So in this particular case, we are using presentation variables for name, region and product. In this particular syntax we have equated the required columns to their respective presentation variables. What we have mentioned after the presentation variable is the default value that will be displayed on taking up the report before passing the prompt.

We may have a requirement wherein we need the report to display all the values without restricting it to the default values in its original view. In this case we need a small change in the SQL entered. The SQL entered will be as follows.



What does this SQL do? When no prompts are passed, the presentation variable is passed as it is. In that scenario, it uses a case statement to make the default value as all values and only take the prompt when it is applied to it.

Once the SQL’s are typed in, click on ‘Validate SQL and Retrieve Columns’.  Once this is done, click on ‘Results’ to view the results.

If you have a revenue column like in our case and want to use the grand total etc in the tabular/ pivot view, you have to make a small change in the Criteria tab. Click on the fx in the measure column. Change the aggregation rule from Default to Sum or Count Distinct or Average as per need.  In our case, it is going to be sum as that is our requirement.




Once this task Is completed, you can view the sum as well.

The other part we have to look into is the creation of presentation variables in the dashboard prompt.

Create variable prompts.


Repeat the process for region and product as well.



Once this is created, we can use this in the dashboard and pass prompts as well.

Cheers,
 Gautam












Wednesday, January 23, 2013

Purging / Disabling the Query Cache


We always need to play around with cache during OBIEE development. Be it disabling it for a particular report or purging for the entire application or a particular table etc. Here we deal with cache related tasks in OBIEE.

DISABLING CACHE


For the Entire Application:

  • Log into your enterprise manager
  • Navigate to Business Intelligence -> coreapplication
  • Select Capacity Management tab and go to the Performance sub tab
  • Once here click ‘Lock and Edit Configuration’       
  • Now you will see a ‘Cache enabled’ tick box.  Untick it disable cache for the entire application.

  • Once this is performed, you will have to activate the changes and then restart services for this to take effect.
From the OBIEE Application one can purge all the cache by doing the following:

  • Go to Administration


  • ·         Navigate to Issue SQL


               Key in:  Call SAPurgeAllCache()

      •     Click “Issue SQL”

        You can also clear the cache of specific databases.

        Call SAPurgeCacheByDatabase( ‘<DB_NAME>’ );
      For a Particular Session:

      For a particular session you will have to set the system session variable with the value 1.

      • DISABLE_CACHE_HIT
      • DISABLE_CACHE_SEED

      For a Particular Analysis:

      For a particular analysis, you will have to set the request variable with the values 1.
      • DISABLE_CACHE_HIT
      • DISABLE_CACHE_SEED

      Once this is written in the prefix, click ‘apply’ and the query will not be taken from cache. You can also go without specifying the log level. In that case the query will be generated using the existing log level.


      PURGING CACHE

      Using Dynamic Repository Variable:

      When the value of a dynamic repository variable changes, all cache entries associated with a business model that reference the value of that variable will be purged automatically. This pretty much means that when the variable is refreshed, the cache will be purged.

      For Example, if you need your cache purged every time an ETL process happens, create a dynamic repository variable which gets populated with the last_updated_date  from your warehouse.

      Manually using Cache Manager:

      • Open the rpd in online mode.
      • Go to Manage -> Cache
      • You will see the different Business Models. You can either purge the cache for a particular Business Model or the entire rpd. 

      Using Event Polling Tables:

      Event Polling table is a mechanism of notifying the OBI Server that one or more of the physical tables have been updated. The OBI server cache system reads rows from event table, extracts the physical table information from the rows, and purges cache entries that reference those physical tables.

      Setting Cache Persistence Time:

      For a particular table, you can purge the cache automatically by setting the cache persistence time in Physical Table. It can be in Days, Hours, Minutes or seconds duration.



      Cheers,
       Gautam










      Tuesday, January 22, 2013

      HTML Scripts for Different Dashboard Buttons


      Buttons in a Dashboard! This is something that pretty much comes up in every single development that we do. I end up googling the result every single time. So finally decided to put it up as a reference for my own sake.

      HTML script’s for the buttons are as mentioned below.

      Return Link (Go Back one page)

      <div class="XUIPromptEntry minibuttonOn" align="left"><input type= "button" value = "Go Back one Page" onclick="history.back();">

      This is pretty much used to go back one page.

      Return Link (Go Back two pages)

      <div class="XUIPromptEntry minibuttonOn" align="left"><input type= "button" value = "Go Back two Pages" onclick="history.go(-2);">

      Consider a condition wherein we navigate from one a dashboard to another dashboard. And from this dashboard we have to navigate to another dashboard.  Also consider that we reach this detailed dashboard page from multiple summary dashboard pages. In this case we cant give one particular URL in the HTML as it is from multiple url’s that you end up here. So we use a go 2 pages back HTML script.

      Button back to a particular Dashboard

      <div class="XUIPromptEntry minibuttonOn" align="left"><a href="URL of Dahboard from saw.dll onwards">Name of Button</a></div>

      Example: <div class="XUIPromptEntry minibuttonOn" align="left"><a href="saw.dll?Dashboard&PortalPath=%2Fshared%2FG%2F_portal%2FG&page=Geo Revenue Trend">Back to Summary</a></div>

      This is often used so as to end up in a particular dashboard as per the requirement.

      Button back to a particular URL

      <div class="XUIPromptEntry minibuttonOn" align="left"><a href="http://google.com"><OnClick="MyFunction(getURL)> Click here</a></div>

      This is often used to navigate to a particular URL using one of the dashboard buttons.

      Cheers!
      -         Gautam

      OBIEE Date Expression Reference


      Often en course of your development, you need to use a lot of customized date functionality in OBIEE.

      Here is a one stop shop for all the First and Last days of the Current/ Previous/ Next (Year/ Quarter/ Month/Week)

      PREVIOUS - (YEAR/ QUARTER/  MONTH/WEEK)

      First Day of the Previous Year

      TIMESTAMPADD( SQL_TSI_YEAR , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) 

      First Day of Previous Quarter

      TIMESTAMPADD( SQL_TSI_QUARTER , -1, TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))

      First Day of the Previous Month

      TIMESTAMPADD(SQL_TSI_MONTH, -1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) 

      First Day of the Previous Week

      TIMESTAMPADD(SQL_TSI_DAY, ((DAYOFWEEK(CURRENT_DATE) *-1)-6),CURRENT_DATE)

      Last Day of Previous Year

      TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1,  CURRENT_DATE)) 

      Last Day of Previous Quarter

      TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))

      Last Day of the Previous Month

      TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) 

      Last Day of the Previous Week

      TIMESTAMPADD(SQL_TSI_DAY, (DAYOFWEEK(CURRENT_DATE) *-1),CURRENT_DATE)

      CURRENT - (YEAR/ QUARTER/  MONTH/WEEK)

      First Day of the Current Year

      TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE) 

      First Day of Current Quarter

      TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE) 

      First Day of the Current Month

      TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE) 
       
      First Day of the Current Week

      TIMESTAMPADD(SQL_TSI_DAY, ((DAYOFWEEK(CURRENT_DATE) *-1)+1),CURRENT_DATE)

      Last Day of Current Year

      TIMESTAMPADD(SQL_TSI_YEAR, 1, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) 

      Last Day of Current Quarter

      TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_QUARTER , 1, TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) 

      Last Day of Current Month

      TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) 

      Last Day of Current Week

      TIMESTAMPADD(SQL_TSI_DAY, ((DAYOFWEEK(CURRENT_DATE) *-1)+7),CURRENT_DATE)

      NEXT - (YEAR/ QUARTER/  MONTH/WEEK)

      First Day of the Next Year

      TIMESTAMPADD( SQL_TSI_YEAR , 1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) 

      First Day of Next Quarter

      TIMESTAMPADD( SQL_TSI_QUARTER , 1, TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))

      First Day of the Next Month

      TIMESTAMPADD(SQL_TSI_MONTH, 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))

      First Day of the Next Week

      TIMESTAMPADD(SQL_TSI_DAY, ((DAYOFWEEK(CURRENT_DATE) *-1)+8),CURRENT_DATE)

      Last Day of the Next Year

      TIMESTAMPADD(SQL_TSI_YEAR, 2, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) 

      Last Day of Next Quarter

      TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_QUARTER , 2, TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))

      Last Day of the Next Month

      TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 2, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) 

      Last Day of the Next Week

       TIMESTAMPADD(SQL_TSI_DAY, ((DAYOFWEEK(CURRENT_DATE) *-1)+14),CURRENT_DATE)

      Cheers!

      -Gautam