Variables

Variables and Input Parameters in HANA:

Sometimes we need to filter the data based on user's input. This is where Input Paramters and Variables come into the pictures.
Input parameters and variables are used to filter the result of modeling views.


Let us first see what is Variable and how does it work. 

Introduction to variables:

Variables are bound to columns and are used for filtering using WHERE clauses. As such, they can only contain the values available in the Columns they relate to. 

Sounds confusing?? Let us take a simple example. 
In the previous chapter, we created a calculation view which has 4 columns PRODUCT_NAME, REGION_NAME, SUB_REGION_NAME and SALES_AMOUNT. 
REGION_NAME contains different regions like “America”, “Asia” and “Europe”. The calculation view gives all the region’s details in output. 


Now suppose we want to filter the data on region basis. The calculation view will prompt the user to specify Region Name and the output data will be filtered based on that. 
For example if the user provides the value as “Asia”, the calculation view will show data only for “Asia” region. 



How to create and use variables in modeling view:

Now we will see how to implement this using variable.
1. Open the calculation view. On Right-Bottom side you will see a pane called “Variables/Input Parameters”. Click on the down arrow of “+” icon and select “Variable” 


2. Specify Name of the Variable. Click on the drop down arrow besides “Attribute” and select REGION_NAME. Click on ok.  


3. Activate the calculation view. Now click on the data preview.
4. A pop-up window will appear. Click on Open Value Help besides “From” and select “Asia” region. Click on ok. 


5. Go to Raw Data tab to see complete output. It contains data only for “Asia” region. 


Important features of variables:
  • You use variables to filter data at runtime. You assign values to these variables by entering the value manually, or by selecting it from the drop-down list.
  • You can also define whether the Variable is Mandatory or if it should have a Default Value.
  • You can apply variables only in analytic and calculation views.


Variable Types:

The following types of Variables are supported:
  • Single Value: Use this to apply a filter to a Single Value.
  • Interval: Use this where you want the user to specify a set start and end to a selected Interval.
  • Range: Use this when you want the end user to be able to use operators such as “Greater Than” or “Less Than”.


System Tables to see Variable Information:

There are 4 system tables under the schema _SYS_BI which contains information about Variables.
  • BIMC_VARIABLE
  • BIMC_VARIABLE_ASSIGNMENT
  • BIMC_VARIABLE_VIEW
  • BIMC_VARIABLE_VALUE

No comments:

Post a Comment