Databases Reference
In-Depth Information
Fortunately, this is a lot easier than it sounds; SAP HANA provides a large number of functions to
do different tasks—you'll see them in the
Functions
pane. Have a look at these functions; most
of the function names are fairly self-explanatory, and they have been grouped together into
categories (just like Excel really).The two we'll be using are
int()
and
string()
.
In the
Elements
pane, you'll see the different components (attributes, measures, calculated
attributes, and so on) of the analytic view—any or all of these can be used when you create your
calculation. You can even mix and match your attributes and measures. For example, you could
create a
PROGRESSION
column (calculated attribute) when the sales for a year for a particular
customer (
ORDER_AMT
, measure) are higher this year than their sales last year (
ORDER_
YEAR
, attribute). We'll be using the private attribute,
ORDER_YEAR
.
In the
Expression Editor
window, enter
string(int("ORDER_YEAR")+1)
.
We can now add our calculated attribute, then save, activate, and do a data preview on our view
to see the results.
As expected, we have a new column, called
NEXT_YEAR
, which contains the value
2012
, as
shown in the following screenshot:
Of course, if we change the filter on the view, to filter on the year
2010
instead of
2011
, then
the
NEXT_YEAR
column will take the value
2011
instead of
2012
. If you decide to check this,
then please make sure you restore the filter to the default value of
2011
, or else the rest of our
simulator won't work right.
Input Parameters
One of the more useful features of SAP HANA is the input parameter. This allows an application
to be developed where the results depend on the input of the user at runtime. This input can be
used to filter results, to perform calculations, and so on.
In our simulation application, we're going to ask the user to tell us by how much the company
sales are expected to increase next year. When we run the application, we'll be asked to fill in the
value, and then we can use this value to calculate our projected sales.