Calculation View

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Explore

A calculation view in SAP HANA is a virtual data model that allows you to perform
complex calculations on data from various sources. You can create graphical or SQL
Script-based calculation views using SAP HANA Studio or Eclipse 1.

A graphical calculation view consists of nodes that represent different operations,


such as projection, aggregation, join, union, and rank. You can drag and drop tables,
views, or other calculation views as data sources and map the columns to the output.
You can also define filters, variables, and parameters to customize the data selection
and calculation logic 23.

A SQL Script-based calculation view is a user-defined function that returns a table as


output. You can write SQL statements to manipulate data from tables, views, or other
calculation views. You can also use SQL Script features, such as control structures,
expressions, and procedures, to implement complex logic 1.

Here is an example of a graphical calculation view that aggregates the sales amount
by product category and region:
calculation view: SALES_BY_CATEGORY_REGION
output columns: CATEGORY, REGION, AMOUNT
aggregation node: AGGREGATE_SALES
data source: SalesItems table
mapped columns: CATEGORY, REGION, AMOUNT
aggregation type: MAX for AMOUNT column
Here is an example of a SQL Script-based calculation view that returns the top 10
customers by revenue:
calculation view: TOP_CUSTOMERS
output columns: CUSTOMER_ID, CUSTOMER_NAME, REVENUE
SQL Script:

CREATE FUNCTION TOP_CUSTOMERS ( )


RETURNS TABLE ( CUSTOMER_ID INTEGER, CUSTOMER_NAME VARCHAR(100), REVENUE
DECIMAL(15,2) )
AS
BEGIN
RETURN (
SELECT TOP 10 C.ID AS CUSTOMER_ID, C.NAME AS CUSTOMER_NAME, SUM(S.AMOUNT)
AS REVENUE
FROM CUSTOMERS C
INNER JOIN SALES S ON C.ID = S.CUSTOMER_ID
GROUP BY C.ID, C.NAME
ORDER BY REVENUE DESC
);
END;

You might also like