Using Variables in OBIEE

Using Variables
You can reference variables in several areas of Oracle BI Enterprise Edition, including in analyses, dashboards, KPIs, actions, agents, and conditions. For example, suppose that you wanted to create an analysis whose title displays the current user's name. You can do this by referencing a variable. There are four types of variables that you can use:
   

Session Repository Presentation Request

Session Variables
A session variable is a variable that is initialized at login time for each user. When a user begins a session, the Oracle BI Server creates a new instance of a session variable and initializes it. There are as many instances of a session variable as there are active sessions on the Oracle BI Server. Each instance of a session variable could be initialized to a different value. There are two types of session variables:

System — A session variable that the Oracle BI Server and Oracle BI Presentation Services use for specific purposes.

System session variables have reserved names that cannot be used for other kinds of variables (such as static or dynamic repository variables and non-system session variables).

Non-system — A system variable that the administrator creates and names. For example, the administrator might create a SalesRegion non-system variable that initializes the name of a user's sales region.

The administrator creates non-system session variables using the Oracle BI Administration Tool.

and you define the values that it can take. The administrator creates repository variables using the Oracle BI Administration Tool. and the values that it can take come from the column values. you have to select Presentation Variable in the Prompt for field and then enter a name for the variable in the Variable Name field. To create a presentation variable as part of a column prompt. There are two types of repository variables:   Static — Repository variables whose value persist and do not change until the administrator decides to change them.Repository Variables A repository variable is a variable that has a single value at any point in time. each time a user selects a value in the column or variable prompt. The value of a presentation variable is populated by the column or variable prompt with which it was created. Dynamic — Repository variables whose values are refreshed by data returned from queries. That is. Presentation Variables A presentation variable is a variable that you can create as part of the process of creating one of the following types of dashboard prompts:  Column prompt — A presentation variable created as part of a column prompt is associated with a column. To create a presentation variable as part of a variable prompt. in the "New Prompt dialog" (or Edit Prompt dialog). To create a request variable as part of a column prompt. the value of the presentation variable is set to the value that the user selects. in the "New Prompt dialog" (or Edit Prompt dialog). in the "New Prompt dialog" (or Edit Prompt dialog). A request variable that is created as part of a column prompt is associated with a column. you have to select Request Variable in the Set a variable field . Request Variables A request variable lets you override the value of a session variable but only for the duration of a database request initiated from a column prompt.  Variable prompt — A presentation variable created as part of a variable prompt is not associated with any column. and the values that it can take come from the column values. you have to select Presentation Variable in the Set a variable field and then enter a name for the variable in the Variable Name field. You can create a request variable as part of the process of creating a column prompt.

Conditional formatting conditions. however. URL fields in dialogs. Filters. . For other tasks. Conditions to specify parameters. KPIs to define thresholds. Gauge thresholds. The value. How you reference a variable depends on the task that you are performing. each time a user selects a value in the column prompt. Column formulas. such as referencing a variable in a title view. for example. is in effect only from the time the user presses the Go button for the prompt until the analysis results are returned to the dashboard. you specify the variable syntax. the value of the request variable is set to the value that the user selects. KPIs included in a KPI watchlist. The syntax you use depends on the type of variable as described in Table 1. Static text views. Actions to specify parameters. Gauge limits. Link or image objects in a dashboard. The value of a request variable is populated by the column prompt with which it was created. Syntax for Referencing Variables You can reference variables in analyses. Dashboard prompts and inline prompts. That is. Selection steps. Narrative views. For tasks where you are presented with fields in a dialog. Agents. Where Can I Reference Variables? You can reference variables in the following areas (but not all types of variables can be referenced in each area):                       Title views. KPIs. Table and column headings in analyses. Graphs to specify conditional formatting of graph data. and agents. referencing a variable in a filter definition. you must specify only the type and name of the variable (not the full syntax).and then enter the name of the session variable to override in the Variable Name field. Headers and footers for PDF output. dashboards. Direct database requests. Text objects in a dashboard.

variablename} y or @{biServer. (Note that the format is not applied to the default value. scope identifies the qualifiers for the variable.USER']} where variablename is the name of the session variable.prime_begin} or @{biServer.MyFavoriteRegion}{EA ion or ultvalue} STERN REGION} request or or @{scope.variablename}[format]{defa @{variables.) (optional) defaultvalue is a constant or variable reference indicating a value to be used if the variable referenced by variablename is not populated. for example.variables['variablename']} where:  @{dashboard. then it is treated as an "at" sign.varia @{biServer.variables. prime_begin. You must specify the .##0.variables['MyFavorit eRegion']} variablename is the name of the    presentation or request variable.variables['prime_begin' ]} Presentat @{variables. MM/DD/YY hh:mm:ss. for example. Repositor @{biServer. MyFavoriteRegion. if the "at" sign (@) is not followed by a brace ({).variables. (optional) format is a format mask dependent on the data type of the variable. @{biServer.variables['variablename']} where variablename is the name of the repository variable.Note: In the syntax.variables['NQ_SESSION. for example #.variables['NQ_SESSIO blename']} N. for example DISPLAYNAME. Table 1 Syntax for Referencing Variables Type of Variable Syntax Session Example @{biServer.

Include the repository variable as an argument of the VALUEOF function. Enclose the variable Reposit ory  CASE WHEN "Hour" >= VALUEOF("prime_begin") AND "Hour" < VALUEOF("prime_end") THEN 'Prime Time' WHEN ."SalesRegion") variable as an argument of the VALUEOF function. ELSE. Precede the session variable by NQ_SESSION and a period. Table 2 Guidelines for Referencing Variables in Expressions Type of Variabl e Guidelines Session  Example    "Market". Enclose the variable name in double quotes. Enclose both the NQ_SESSION portion and the session variable name in parentheses."Region"=VALUEOF(NQ_SESS Include the session ION. dashboard pages. (If you do not specify the scope.Type of Variable Syntax scope when a variable is used at multiple levels (analyses.. dashboard pages. then the order of precedence is analyses.END  . and dashboards. The guidelines for referencing variables in expressions are described in Table 2.. and dashboards) and you want to access a specific value..) Example You also can reference variables in expressions..

Refer to a dynamic repository variable by its fully qualified name."Region"=@{MyFavoriteReg ion}{EASTERN REGION} @{variablename}{def aultvalue} where variablename is the name of the presentation variable and defaultvalue (optional) is a constant or variable reference indicating a value to be used if the variable referenced by . to use the value of a dynamic repository variable named REGION contained in a initialization block named Region Security. use this syntax: VALUEOF("Region Security"."REGION") Present ation   Use this syntax: "Market". then the names of the initialization block and the repository variable must be enclosed in double quotes ("). Refer to a static repository variable by name. separated by a period. Example   If you are using a dynamic repository variable. For example. and contained within parentheses.Type of Variabl e Guidelines name in double quotes.

for example:  '@{user. convert) the variable to a string.Type of Variabl e Guidelines Example variablename is not populated.displayName }' Note: If the @ sign is not followed by a {. then it is treated as an @ sign. . enclose the entire syntax in single quotes.  To type-cast (that is.