About Semantic Model Variables

A semantic model variable contains a single value at any point in time. You use a variable instead of a literal or constant in data filters and expressions.

Types of Variables

You can create three types of semantic model variables:

  • Global variables - A global variable has the same value for all users. You can let the system set the value, or specify a schedule to set the value. For example, you can define current period or current year as a global variable.
  • Session variables - A session variable's value is specific to a user's session and is usually set when a user logs into Oracle Analytics, for example, user department or sales region.
  • Static variables - A static variable holds a value that doesn't change, for example, minimum credit score or preferred credit score.

About Initialization Blocks and Variables

A global or session variable's initialization block contains a default initialization query that is run to initialize or refresh the variables defined in the initialization block. The initialization query references the data source's tables that supply the variable values. A query can populate values into several variables, that is one variable for each column in the query. You must also specify a connection pool that the initialization query uses to access the data source and return the variable values.

In addition to the default initialization query, you can choose to create data source-specific initialization queries for the data sources that your company is using (for example, Snowflake or DB2). If you define an additional initialization query, then Oracle Analytics uses it rather than the default initialization query to instantiate the initialization block and populate the variables.

For example, suppose you're an Oracle Fusion Cloud Applications customer and your data source is Snowflake. The semantic model delivered with Oracle Fusion Cloud Applications contains variables with their initialization queries written for Oracle Autonomous Database. To ensure that the variables included in the semantic model delivered with Oracle Fusion Cloud Applications work properly in your instance, you must modify the initialization blocks containing the variables to include an additional initialization query written for the Snowflake data source.

A static variable's initialization block doesn't contain an initialization query. To define a static variable, you specify the variable name and value.

After you define the variables in the initialization block, the variables are then available for you to include in data filters and expressions.

About Variables In Semantic Model Data Filters and Expressions

Variables are available for you to include in data filters and expressions. You use variables instead of literals or constants in expressions. You can't use variables to represent columns or other semantic model objects.

Variables are arguments of the function VALUEOF(). For example:

CASE WHEN "Hour" >= VALUEOF("prime_begin")AND "Hour" < VALUEOF("prime_end") THEN 'Prime Time' WHEN ... ELSE...END

The Semantic Modeler displays the Variables tab in the Expression Editor. The Variables tab lists the variables that you can use in a data filter or expression. When you double-click a variable, the Expression Editor inserts the VALUEOF() function and the variable name.


Expression Editor Variables Tab