Databases Reference
In-Depth Information
Creation of a calculated measure is done in exactly the same way as a calculated attribute—
right-click on Calculated Measures in the Output pane of the view, and select New . We are
presented with exactly the same dialog as when we created our calculated attribute earlier; the
only difference being that this time, instead of creating text-type columns, we are presented
with a list of numeric types in the Data Type field.
Give the calculated measure a name and a description ( PROJECTED_SALES ) and a data
type ( INTEGER ).
In the Formula Editor window, we want to calculate a value based on the ORDER_AMT field,
and increase this value by the percentage amount the user enters in our SALES_INCREASE_
PERCENT variable.
You'll see, in the same way as for the calculated attribute we created earlier, that in the
Elements pane our ORDER_AMT field and SALES_INCREASE_PERCENT variable are
available for use:
If you double-click on the field and then the variable, they'll be added to the Formula Editor
window. ORDER_AMT will appear as "ORDER_AMT" and SALES_INCREASE_PERCENT will
be surrounded with $$ . These dollar signs indicate that we're talking about a variable, and that
the value will be supplied at runtime.
The formula to calculate the projected sales as a percentage increase of ORDER_AMT is
(("ORDER_AMT" * $$SALES_INCREASE_PERCENT$$) / 100) + "ORDER_AMT" .
Please enter this formula as it appears here into the Formula Editor window. Be careful with
the brackets—they're important. SAP HANA will perform the calculation we enter respecting
mathematical rules of precedence; the brackets make sure calculations are done in the order we
specify (notably that the multiplication is done before the division)—if not, then the values will
be divided by 100 before being multiplied by the percentage increase, and since the fields are
of type INTEGER , the result will be 0 .
Once that's done, save the calculated measure, and reactivate the analytic view.
Search WWH ::




Custom Search