Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Calc View Star Join PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 74

1/10/2020

SAP Web IDE Full-Stack Modeling Guide


Generated on: 2020-01-10

SAP Cloud Platform | Cloud

PUBLIC

Original content: https://help.sap.com/viewer/3746eb56b77943b699df025ab2bc7552/Cloud/en-US

Warning

This document has been generated from the SAP Help Portal and is an incomplete version of the official SAP product
documentation. The information included in custom documentation may not re ect the arrangement of topics in the SAP Help
Portal, and may be missing important aspects and/or correlations to other topics. For this reason, it is not for productive use.

For more information, please visit the https://help.sap.com/viewer/disclaimer.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b4… 1/74
1/10/2020

Creating a Graphical Calculation View


A calculation view allows users to de ne more advanced slices on the data available in the SAP HANA database.

Calculation views are mainly used for analyzing operational data marts or running multidimensional reports on revenue,
pro tability, and more. Calculation views consume various combinations of content data (that is, non-metadata) to model a
business use case. You can classify content data as:

Attributes: Descriptive data - such as customer ID, city, and country.

Measures: Quanti able data - such as revenue, quantity sold, and counters.

Calculation views simulate entities (such as customer, product, sales, and more) and their relationships. Data visualization and
analysis applications such as SAP BusinessObjects Explorer and Microsoft Office based reporting tools consume these calculation
views and help decision makers in their decision process.

You can create calculation views with layers of calculation logic, which include measures sourced from multiple source tables, or
advanced SQL logic, and much more. The data sources in a calculation view can include any combination of tables and calculation
views. You can create joins, unions, projections, and aggregations on data sources.

Calculation views can include measures and be used for multidimensional reporting, or can contain no measures and used for list-
type reporting. Calculation views can do the following:

Support both OLAP and OLTP models.

Support complex expressions (for example, IF, Case, Counter).

Support analytic privileges (for example, restricting a user for a certain cost center).

Support SAP ERP speci c features (for example, client handling, language, currency conversion).

Combine facts from multiple tables.

Support additional data processing operations (for example, Union, explicit aggregation).

Leverage both Column and Row tables.

Related Information
Attributes and Measures
Create Graphical Calculation Views
Preview Calculation View Output

Attributes and Measures


Attributes and measures form content data that you use for data modeling. The attributes represent the descriptive data, such as
region and product. The measures represent quanti able data such as revenue and quantity sold.

Attributes
Attributes are the nonmeasurable analytical elements.

Attributes Description Example

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b4… 2/74
1/10/2020

Attributes Description Example

Simple Attributes Individual nonmeasurable analytical elements For example, PRODUCT_ID and PRODUCT_NAME are
that are derived from the data sources. attributes of product data source.

Calculated Attributes Derived from one or more existing attributes For example, deriving the full name of a customer ( rst
or constants. name and last name), assigning a constant value to an
attribute that can be used for arithmetic calculations.

Measures
Measures are measurable analytical elements that are derived from calculation views.

Measures Description Example

Simple Measures A simple measure is a measurable analytical For example, PROFIT.


element that is derived from the data sources.

Calculated Measures Calculated measures are de ned based on a For example, you can use calculated measures to
combination of data from other data sources, calculate the net pro t from revenue and operational
arithmetic operators, constants, and functions. cost.

Counters Counters add a new measure to the calculation For example, to count how many times product appears
view de nition to count the distinct and use this value for reporting purposes.
occurrences of an attribute.

Related Information
Working With Attributes and Measures

Required Authorizations
The Object Owner user and the Application user by default have the authorizations that they require to model calculation views
including _SYS_BI access.

Modeling

This tables describes the authorizations required for modeling calculation views.

User Type Authorizations Description

Object Owner
SELECT with GRANT on objects used in These authorizations are assigned
modeling. automatically for objects within the same
container. But, for objects outside the
container, the authorizations must be
granted with the .hdbgrants le.

Application User
SELECT on objects used in modeling SELECT on objects are assigned by
default, but must be granted for objects
SELECT on schema _SYS_BI outside the container.

Analytic Privileges, if required.


SELECT on schema is automatically
assigned.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b4… 3/74
1/10/2020
Reporting

For reporting purposes, users require SELECT on the calculation view, SELECT on _SYS_BI, and if applicable, even analytic
privileges. If the calculation view is used in another calculation view, then users require SELECT on the higher-level calculation
view.

Create Graphical Calculation Views


Create graphical calculation views using a graphical editor to depict a complex business scenario. You can also create graphical
calculation views to include layers of calculation logic.

Context
Graphical calculation views can bring together normalized data that are dispersed. You can combine multiple transaction tables
while creating a graphical calculation view.

Procedure
1. Start SAP Web IDE in a Web browser.

2. If you want to create a new project for the calculation view, do the following:

a. In the SAP Web IDE, choose File New Project from Template .

b. Choose the project template type.

Currently, there is only one type of project template available, namely: Multi-Target Application Project. Select
Multi-Target Application Project and choose Next.

c. Type a name for the new MTA project (for example, myApp and choose Next to con rm).

d. Specify details of the new MTA project and choose Next to con rm.

e. Create the new MTA project; choose Finish.

3. Select the SAP HANA Database Module in which you want to create the calculation view.

 Tip
If you do not already have a database module, right-click the root folder of your new MTA project and, in the context
menu, choose New SAP HANA Database Module .

4. Browse to the src folder, right-click it and choose New Calculation View .

5. Enter the details for the new calculation view.

a. In the Name eld, enter the name of the calculation view.

b. In the Data Category dropdown list, select a value.

6. Choose Create.

The tool launches a new graphical calculation view editor with a semantics node and a default view node. The default view
node can be an aggregation or a projection view node and depends on the data category that you have selected while
creating the calculation view. If you are creating a calculation view with star join, then the default view node is a star join
view node.

 Note
You can switch between the default view nodes. For example, from a default aggregation view node to a project view
node or a star join view node. Right-click the default view node and select the required menu option.

7. Continue modeling the graphical calculation view by dragging and dropping the necessary view nodes from the tool palette
to the view editor. You can switch between any of the inner aggregation or projection view nodes by right-clicking the view
node and selecting the required menu option. The tool retains the same name after the switch operation.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b4… 4/74
1/10/2020
8. Add data sources.

If you want to add data sources to the view node,

a. Select a view node.

b. In the editor toolbar, choose (Expand Details Panel).

c. Choose (Add Data Source).

d. In the Find Data Sources dialog box, select the type of the data source.

e. Enter the name of the data source and select it from the list.

You can add one or more data sources depending on the selected view node.

f. Choose Finish.

 Note
Supported data sources in view nodes in the current version.

The Find Data Sources dialog box displays multiple object types in the search result. But, depending on the
selected view node, you can only add activated (built) catalog tables, calculation views, CDS entities, CDS views,
and table functions as data sources in the view nodes.

9. (Optional) Add data sources from external services (HDI or non HDI containers).

You can use synonyms to access objects from user-de ned schemas (non HDI) or from HDI containers. The tool
automatically creates (or modi es the existing) .hdbsynonym, .hdbgrants, and .hdbsynonymconfig (for objects
in HDI), les that are necessary to consume the synonym.

 Note
You can access data sources from external services only if you have created the necessary user-provided service and
con gured it in the mta.yaml le. For more information see, Add an External Service in the mta.yaml File.

a. Select a view node.

b. Choose (Add Data Source).

The tool opens the Find Data Sources dialog box.

c. In the External Services dropdown list, select the required external service.

d. Enter the name of the data source you want to access from the external service and select it from the search list.

You can add one or more data sources depending on the selected view node.

e. Choose Create Synonym.

f. (Optional) Modify the synonym name.

g. De ne the object owner role and the application user role.

Object Type Steps

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b4… 5/74
1/10/2020

Object Type Steps

Objects in HDI If the selected object is from a HDI container,


Containers
1. In the Object Owner Role, enter the name of the object owner role.

2. In the Application User Role, enter the name of the application user role.

For more information on roles for HDI containers, see the topic, Roles (.hdbrole) in the SAP HANA
Developer Guide (for XS Advanced).

If the object for which you are creating the synonym is in a HDI container, select Synonym for HDI
Container. This selection helps the tool identify that you are creating synonym for an object in the
HDI container.

Objects in non HDI If the selected object is from a HDI container,


containers
1. In the Object Owner Role, enter the name of the object owner role.

2. In the Application User Role, enter the name of the application user role.

For more information on roles for non HDI containers, see the topic, Enable Access to Objects in a
Remote Classic Schema in the SAP HANA Developer Guide (for XS Advanced).

 Note
If the object for which you are creating the synonym is in a non HDI container, ensure that you
have not selected the Synonym for HDI Container checkbox.

h. Choose Finish.

The tool creates the synonym along with the .hdbsynonym, .hdbgrants, and .hdbsynonymconfig (for
objects in HDI) les in the same SAP HANA Database Module.

10. De ne output columns.

a. Select a view node.

b. On the Mapping tab, select the column you want to add to the output.

c. In the context menu, choose Add To Output.

d. If you want to add all columns in a data source to the output, then from the context menu of the data source, select
Add To Output.

 Note
Using keep ag property. The Keep Flag property on attribute columns in uence the result set. Use Keep Flag
property, for example, if you want to aggregate the measures by performing an SQL GROUP BY operation on
them, even when they are not included in the query.

i. Select the view node.

ii. On the Mapping tab, select an output column.

iii. In the Properties section, set the value of Keep Flag property to True.

11. De ne attributes and measures.

To successfully activate a calculation view with data category as CUBE, you must specify at least one column as a measure.

a. Select the Semantics view node.

b. On the Columns tab, select a column value.

c. In the Type dropdown list, select Measure or Attribute.

If the data category is set to Cube, an additional aggregation column is available to specify the aggregation type for
measures.

12. (Optional) Copy a calculation view.


https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b4… 6/74
1/10/2020
You can copy a calculation view and paste it using a different name within the same or different SAP HANA Database
module. The tool automatically adjusts the calculation view ID in the view properties.

a. In the Workspace view, right-click the required calculation view.

b. Choose Copy.

c. Right-click at the target folder and choose Edit Paste .

d. Provide a new name.

e. Choose OK.

13. (Optional) View modeler objects in the outline pane.

Use the outline pane in SAP Web IDE to obtain a quick overview of the modeler objects (view nodes and columns) in the
calculation view.

a. In the menu bar, choose View Outline .

The tool displays all modeler objects in the calculation view. You can also select an object in the outline pane, and
navigate to the editor to identify where the object is used in the calculation view.

b. In the right menu bar, choose (Outline) to show or hide the outline pane.

14. Choose Save on the menu bar to save your calculation view.

15. Build an SAP HANA Database Module.

The build process uses the design-time database artifacts to generate the corresponding runtime objects in the database
catalog.

a. From the module context menu, choose Build.

Next Steps
After creating a graphical calculation view, you can modify the output to your needs. The following table shows how you can
modify the calculation view.

Working With View Nodes

Requirement Task to Perform

Query data from two data sources and combine records from both the data sources, based on a Create Joins
join condition, or to obtain language-speci c data.

Combine the results of two or more data sources. Create Unions

Partition the data for a set of partition columns, and perform an order by SQL operation on the Create Rank Nodes
partitioned data.

Execute any of the available graph operations on the graph workspace. Create Graph Nodes

Model calculation views with SAP HANA hierarchy functions. Use Hierarchy Functions

Anonymize calculation view output. Anonymize Data Using Calculation


Views

Filter the output of view nodes. Filter Output of View Nodes.

Working With Columns

Requirement Task to perform

Count the number of distinct values for a set of attribute columns. Create Counters

Create new output columns and calculate their values at runtime using an expression. Create Calculated Columns

Assign semantic types to provide more meaning, and to attach information about the type of Assign Semantics
attributes and measures in calculation views.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b4… 7/74
1/10/2020

Requirement Task to perform

Parameterize calculation views and execute them based on the values users provide at query Create Input Parameters
runtime.

Filter the results based on the values that users provide to attributes at runtime. Assign Variables

Create level hierarchies to organize data in reporting tools. Create Level Hierarchies

Create parent-child hierarchies to organize data in reporting tools. Create Parent-Child Hierarchies

Associate measures with currency codes and perform currency conversions. Associate Measures with Currency

Associate measures with unit of measures and perform unit conversions. Associate Measures with Unit of
Measure

De ne default values for columns (both attributes and measures) when no value is provided Handle Null Values in Columns
during a SQL INSERT operation.

Group related measures and related attributes together in a folder. Group Related Measures and Attributes

Working With Calculation View Properties

Requirement Task to perform

Filter the view data either using a xed client value or using a session client set for the user. Filter Data for Speci c Clients

Invalidate or remove data from the cache after speci c time intervals. Invalidate Cached Content

Prevent use of a calculation view. Deprecate Calculation Views

Execute time travel queries on calculation views. Enable Calculation Views for Time Travel
Queries

Related Information
Working With View Nodes
Preview Calculation View Output
Working With Attributes and Measures
Working With Calculation View Properties
Additional Functionality for Calculation Views
De ning Data Access Privileges
Create Graphical Calculation Views with Star Joins
Example: Using Keep Flag

Create Graphical Calculation Views with Star


Joins
Star joins connect a central data entity to multiple entities that are logically related. You can create a graphical calculation view
with star joins that join multiple dimensions to a single fact table.

Context
Star joins in calculation views help join a fact table with dimensional data. The fact table contains data that represent business
facts such as, price, discount values, number of units sold, and more. Dimension tables represent a collection of information. The
information can include entities such as, geography, time intervals, contact names and more.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b4… 8/74
1/10/2020

Procedure
1. Start SAP Web IDE in a Web browser.

2. If you want to create a new project for the calculation view, do the following:

a. In the SAP Web IDE, choose File New Project from Template .

b. Choose the project template type.

Currently, there is only one type of project template available, namely: Multi-Target Application Project. Select
Multi-Target Application Project and choose Next.

c. Type a name for the new MTA project (for example, myApp and choose Next to con rm).

d. Specify details of the new MTA project and choose Next to con rm.

e. Create the new MTA project; choose Finish.

3. Select the SAP HANA Database Module in which you want to create the calculation view.

 Tip
If you do not already have a database module, right-click the root folder of your new MTA project and, in the context
menu, choose New SAP HANA Database Module .

4. Browse to the src folder, right-click it and choose New Calculation View .

5. Enter the details for the new calculation view.

a. In the Name eld, enter the name of the calculation view.

b. In the Data Category dropdown list, select CUBE.

 Note
You can create a star join with data category as CUBE or SQL Access Only only.

c. Select the With Star Join checkbox.

6. Choose Create.

The tool opens a new graphical calculation view editor with a semantics node and a star join node.

7. Add data sources.

a. Select the Star Join node.

b. Choose (Add Data Source).

c. In the Find Data Sources dialog box, enter the name of the calculation view with descriptive data.

 Note
When adding calculation views as a data source in a star join node, you can use only calculation views with these
data category types: dimension or blank.

d. Choose Finish.

8. Add inputs to the star join node.

Continue modeling the graphical calculation view with a cube structure, which includes attributes and measures. The input
to the star join node must provide the central fact table.

9. Maintain star join properties.

a. Select the Star Join node.

b. In the editor toolbar, choose (Expand Details Panel).

c. Choose (Create Join)

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b4… 9/74
1/10/2020
d. Create a join by selecting the required column from the left table, and dragging the cursor to the required column in
the right table.

e. (Optional) If you want to swap the left tables and right tables, then in the Join Creation dialog box, choose
(Swap Table).

f. In the General Properties section, de ne necessary join properties.

10. Choose Save in the menu bar to save your calculation view.

11. Build an SAP HANA Database Module.

The build process uses the design-time database artifacts to generate the corresponding actual objects in the database
catalog.

a. From the module context menu, choose Build.

Create Graphical Calculation Views with


Time Dimension
Add time dimension to a calculation view by using the standard time-related tables as data sources in the calculation view.

Prerequisites
You have the time-related tables with time data or have synonyms to the time-related tables ( M_TIME_DIMENSION_YEAR,
M_TIME_DIMENSION_MONTH, M_TIME_DIMENSION_WEEK, M_TIME_DIMENSION, M_FISCAL_CALENDAR) in the
same SAP HANA Database Module in which you are creating the calculation view.

 Note
You can also generate time data in the standard time-related tables that are available in the _SYS_BI schema and use them as
data sources in the calculation view.

Procedure
1. Start SAP Web IDE in a Web browser.

2. If you want to create a new project for the calculation view, do the following:

a. In the SAP Web IDE, choose File New Project from Template .

b. Choose the project template type.

Currently, there is only one type of project template available, namely: Multi-Target Application Project. Select
Multi-Target Application Project and choose Next.

c. Type a name for the new MTA project (for example, myApp and choose Next to con rm).

d. Specify details of the new MTA project and choose Next to con rm.

e. Create the new MTA project; choose Finish.

3. Select the SAP HANA Database Module in which you want to create the graphical calculation view.

 Tip
If you do not already have a database module, right-click the root folder of your new MTA project and, in the context
menu, choose New SAP HANA Database Module .

4. Browse to the src folder, right-click it and choose New Calculation View .

5. Enter the details for the new calculation view.

a. In the Name eld, enter the name of the calculation view.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 10/74
1/10/2020
b. In the Data Category dropdown list, select Dimension.

c. In the Type dropdown list, select TIME.

d. Select the Auto Create checkbox if you want the tool to automatically include the time-related tables as data
sources in the calculation view, and also to de ne lters and hierarchies in the view based on the selected calendar
type and the granularity.

e. In the Calendar dropdown list, select the required calendar type.

f. If you have selected the Gregorian calendar type, in Granularity dropdown list, select the required granularity.

g. Based on the Calendar type and the Granularity type (for Gregorian), in the Table eld, use the Find Data Sources
dialog box to search and select the time-related tables or the synonyms to the time-related tables.

6. Choose Create.

The tool opens a new calculation view editor. If you have not selected Auto Create, manually include the required time-
related tables as data sources and de ne lters, hierarchies based on your requirement.

 Note
For the Fiscal calendar type, Auto Create only includes the M_FISCAL_CALENDAR table as data source in the
calculation view. It does not automatically de ne any lters or hierarchies in the view.

7. Choose Save in the menu bar to save your calculation view.

8. Build an SAP HANA Database Module.

The build process uses the design-time database artifacts to generate the corresponding actual objects in the database
catalog.

a. From the module context menu, choose Build.

Related Information
Create Time-Related Tables and Generate Time Data
Generate Time Data in the _SYS_BI Schema
Supported Calendar Types For Generating Time Data
Supported Time Range for Generating Time Data

Create Time-Related Tables and Generate


Time Data
The tool allows users to create time-related tables in an SAP HANA Database Module and generate time data into these tables.

Context
You can add a time-dimension to a calculation view by using the time-related tables from an SAP HANA Database Module as data
sources in the view. To generate time data, the tool supports Gregorian and Fiscal calendar types.

Procedure
1. Start SAP Web IDE in a Web browser.

2. In the Workspace view, right-click the SAP HANA Database Module and choose Modeling Actions Maintain Time Tables .

3. In the Generate Time Data dialog box, select the required calendar type.

4. Calendar type - Gregorian.

If you have selected Gregorian as the calendar type, then

a. Select all the required granularity levels for which you want to create the time-related tables.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 11/74
1/10/2020

 Note
For the granularity level Week, specify the rst day of the week.

b. If you want to generate time data into the tables after creating them, select Generate Data After Creation and
specify the From year and To year for which you want to generate time data.

c. Choose Generate.

The tool automatically creates the time-related tables for the selected granularity. Browse to the time_tables folder
under the src folder in the SAP HANA Database Module to access the time-related tables.

5. Calendar type - Fiscal.

If you have selected Fiscal as the calendar type, then

a. Select Create or Update Fiscal Table.

b. If you want to generate time data into the tables after creating them, select Generate Data After Creation and
specify the From year and To year for which you want to generate time data.

c. In the Variant eld, use the value help to search and select the table that contains variant data.

 Note
SAP tables T009 and T009B are typically used to store any variant data.

d. In the Variant dropdown list, select the required variant.

The variant speci es the number of periods along with the start and end dates.

e. Choose Generate.

The tool automatically creates the time-related tables for the selected granularity. Browse to the time_tables folder
under the src folder in the SAP HANA Database Module to access the time-related tables.

Related Information
Generate Time Data in the _SYS_BI Schema
Supported Calendar Types For Generating Time Data
Supported Time Range for Generating Time Data

Generate Time Data in the _SYS_BI Schema


Generate time data into the standard time-related tables that are available in the _SYS_BI schema. You can use these standard
time-related tables as data sources in the calculation view to add a time dimension to the view.

Prerequisites
You have INSERT privileges on the time-related tables. You can use the SAP HANA database explorer to add a SYSTEM database
user.

Context
Use the SAP HANA database explorer to generate time-related data in the standard time-related tables. You can specify the
calendar type and the granularity to generate time data. The tool supports Gregorian and Fiscal calendar types..

Procedure
1. Start the SAP Web IDE in a Web browser.

2. In the left sidebar, choose (Database Explorer).

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 12/74
1/10/2020
3. Select the required HDI service for which the user has INSERT privileges on the time-related tables.

4. In the context menu, choose Generate Time Data.

5. In the Calendar Type dropdown list, select the required calendar type.

6. In the From Year and To Year text elds, enter the start year and end year for which you want to generate time data into the
standard time-related tables.

7. If you have selected Gregorian as the calendar type, in the Granularity dropdown list, select the required granularity.

 Note
For the granularity level Week, specify the rst day of the week.

8. If you have selected Fiscal as the calendar type,

a. In the Schema text eld, enter the name of the variant schema that contains tables having variant data.

 Note
SAP tables T009 and T009B are typically used to store the variant data.

b. In the Variant text eld, enter the required variant.

The variant speci es the number of periods along with the start and end dates.

9. Choose OK.

 Note
For the Gregorian calendar type, the tool generates the time data in the M_TIME_DIMENSION_YEAR,
M_TIME_DIMENSION_MONTH, M_TIME_DIMENSION_WEEK, M_TIME_DIMENSION tables. For the Fiscal
calendar type, the tool generates the time data in the M_FISCAL_CALENDAR table. These tables are available in the
_SYS_BI schema.

Related Information
Create Graphical Calculation Views with Time Dimension
Supported Calendar Types For Generating Time Data
Supported Time Range for Generating Time Data

Supported Calendar Types For Generating


Time Data
In SAP Web IDE the following calendar types are supported for generating time data.

Calendar Type Description

Gregorian Use the Gregorian calendar type, if your nancial year is same as the calendar year, for
example, January to December.

Fiscal Use the Fiscal calendar type, if your nancial year is not same as the calendar year, for
example, March to April.

Supported Time Range for Generating Time


Data

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 13/74
1/10/2020
For the Gregorian calendar type, based on the granularity you choose, the tool provides restrictions on the time range for which
you can generate time data.

For each granularity level, the following table displays the time range that the tool supports for generating time data.

Granularity Range

Seconds <= 5 years

Minutes <= 15 years

Hour <= 30 years

Day <= 50 years

Week <= 50 years

Month <= 50 years

Year <= 50 years

 Note
The following restrictions are applicable for generating time dimension data:

Minimum start year: 1900

Maximum end year: 2200

Maximum years generated: 50

MDX Commands for Time-related Tables


The tables M_TIME_DIMENSION, M_TIME_DIMENSION_WEEK and M_TIME_DIMENSION_MONTH stores time-related
information, which are used in time dimensions.

The lling of these tables can be triggered by the following SQL commands:

MDX UPDATE TIME DIMENSION DAY 2010 2020; --> generates data in "_SYS_BI"."M_TIME_DIMENSION"
MDX UPDATE TIME DIMENSION WEEK 2010 2020; --> generates data in "_SYS_BI"."M_TIME_DIMENSION_WEEK"
MDX UPDATE TIME DIMENSION MONTH 2010 2020; --> generates data in "_SYS_BI"."M_TIME_DIMENSION_MONTH"
MDX UPDATE TIME DIMENSION YEAR 2010 2020; --> generates data in "_SYS_BI"."M_TIME_DIMENSION_YEAR"

MDX Commands for Fiscal Generation

MDX UPDATE FISCAL CALENDAR [<schema for T009 tables>] <variant> <startYear> <endYear> [<mandt>] [WITHL

<> - value of parameter; [] - optional; | - or; all else - constants

If TARGET_SCHEMA is not speci ed, then _SYS_BI is used. Similarly, if TARGET_TABLE is not speci ed, then
M_FISCAL_CALENDAR is used.

MDX Commands for Time Generation

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 14/74
1/10/2020

MDX UPDATE TIME DIMENSION SECOND|MINUTE|HOUR|DAY|WEEK|MONTH|YEAR <startYear> <endYear> [FIRST_DAY_OF_W

<> - value of parameter; [] - optional; | - or; all else - constants.

If TARGET_SCHEMA is not speci ed, then _SYS_BI is used. Similarly, if TARGET_TABLE is not speci ed, then depending on the
granularity, the following tables are used:

M_TIME_DIMENSION_MONTH

M_TIME_DIMENSION_WEEK

M_TIME_DIMENSION_YEAR

M_TIME_DIMENSION

Create Virtual Tables


In SAP Web IDE, you can use a wizard to create virtual tables. Virtual tables allow you to access objects in other databases without
having to replicate to SAP HANA.

Prerequisites
You must already have created a remote source.

Context
The SAP Web IDE supports creating virtual tables with a code editor or a wizard. Creating virtual tables with the wizard helps, for
example, to create virtual tables when you are not aware of the syntax to create them with the code editor. After creating the
virtual tables, you can use them as data source.

Procedure
1. Start SAP Web IDE in a Web browser.

2. If you want to create a new project for the virtual table, do the following:

a. In SAP Web IDE, choose File New Project from Template .

b. Choose the project template type.

c. Type a name for the new project (for example, myApp) and choose Next to con rm.

d. Specify details of the new project and choose Next to con rm.

e. Create the new project; choose Finish.

3. Select the SAP HANA Database Module in which you want to create the virtual table.

 Tip
To create a database module, right-click the root folder of your new project and, in the context menu, choose New SAP
HANA Database Module .

4. Browse to the src folder, right-click it and choose New Virtual Table .

5. In the Create Virtual Object wizard, select a remote source and click Next.

6. Use the lter parameters to search for one or more remote objects you want to create a virtual table from and click Next.

7. Enter a name for the virtual object and click Finish.

Use the naming format namespace::virtual_table_name.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 15/74
1/10/2020
8. Choose Save in the menu bar to save your calculation view.

9. Build an SAP HANA Database Module.

The build process uses the design-time database artifacts to generate the corresponding actual objects in the database
catalog.

a. From the module context menu, choose Build.

Supported View Nodes for Modeling


Calculation Views
The SAP Web IDE graphical calculation view editor offers various view nodes to model calculation views and obtain the desired
output.

The following table lists shows the various view nodes.

View Node Description Icon Example

Use the join view node to query data from For retrieving customer details and location based on the
two data sources, based on a speci ed Postal_Code column in the CUSTOMER and GEOGRAPHY
condition. tables. The CUSTOMER table has columns Customer_ID,
Join
Customer_Name, and Postal_Code. The GEOGRAPHY table
Join view nodes can have two or more has columns Customer_ID, Postal_Code, Region, and
inputs. Country.

Use the non equi join view node to create


join conditions with various comparisions
Non Equi Join
or unequal operators (<, >=, !=, ...) on
several columns.

Use the union view node to combine the


result set of two or more data sources. For retrieving the names of all employees of a store, which has
Union different branches, with each branch maintaining its own
Union view nodes can have two or more employee records table.
inputs.

Use the graph view node to execute any Execute graph actions such as the shortest path or the
of the available graph operations or strongest connection between components in the graph
Graph actions on the graph workspace. workspace. The graph workspace includes the de nition of the
vertex table and edge table that are required to execute the
You can use this view node as the leaf
action.
node in the calculation view only.

Use the projection view node to lter or


obtain a subset of required columns of a
data source (tables, views, table For selecting the employee name and employee department
Projection functions, and more). from a table consisting of many other columns.

Projection view nodes can have only one


input.

Use the aggregation view node to


summarize data for a group of row For retrieving total sales of a product in a month. The
Aggregation values, by calculating values in a column. supported aggregation types are SUM, MIN, VAR, STDDEV,
MAX, COUNT, AVG.
Aggregation view nodes can have only
one input.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 16/74
1/10/2020

View Node Description Icon Example

Use the rank view node to partition the


data for a set of partition columns, and to Retrieving the top ve products, based on sales, from a
Rank
perform an order by operation on the TRANSACTION table with columns PRODUCT and SALES.
partitioned data.

Use the hierarchy function view nodes to


Hierarchy
use SAP HANA hierarchy functions in the
Function
calculation view de nition.

Use the anonymization view nodes to


anonymize calculation view output.
Anonymization
You can use this view node as the leaf
node in the calculation view only.

 Note
You can add data sources, unions, joins, projections, or aggregations as inputs to view nodes.

Related Information
Working With View Nodes

Working With View Nodes


View nodes are the building blocks of calculation views. They help you build complex and exible analytic models, and each view
node type possess specialized capabilities that can trigger advanced features in the database.

This section describes the different view nodes that you can use within graphical calculation views, along with examples of how
you can use them to model calculation views.

Related Information
Create Joins
Create Temporal Joins
Create Unions
Create Rank Nodes
Create Graph Nodes
Filter Output of View Nodes
Use Intersect Set Operation
Use Minus Set Operation
Use Hierarchy Functions
Anonymize Data Using Calculation Views
Model Table Functions as View Nodes

Create Joins
Use join view nodes in calculation views to query data from two or more data sources.

Context

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 17/74
1/10/2020
The join view nodes help combine columns from two data sources using records that are common to both the data sources. By
default, a join is an equi join because the condition to create such joins are based on the equality of two values.

Procedure
1. Open the required calculation view in the view editor.

2. From the tool palette of the editor, drag a join view node to the editor.

3. Add data sources.

a. Select the join view node.

b. Choose (Add Data Source).

c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.

d. Choose Finish.

In the editor canvas, you can view only limited number of columns. However, in the Mapping tab, you can view all columns
from the data sources.

4. De ne output columns.

a. In the editor toolbar, choose (Expand Details Panel).

b. On the Mapping tab, select the columns you want to add to the output of the join view node.

c. In the context menu, choose Add To Output.

 Note
If you want to add all columns of a data source to the output, in the context menu of the data source, choose Add
To Output.

5. Create a join between two data sources.

a. Choose the Join De nition tab.

b. Choose (Create Join)

c. Create a join by selecting the required column from the left table, and dragging the cursor to the required column in
the right table.

d. (Optional) If you want to swap the left tables and right tables, then in the Join Creation dialog box, choose
(Swap Table).

If you have more than two data sources in the join view node, you can create multiple join de nitions within a single
join view node (multi join). For each join de nition, in the Left Table dropdown list and in the Right Table dropdown
list, you can select the required left table and right table for the join de nition.

6. De ne join properties.

a. In the Join Creation dialog box, expand the General Properties section.

b. De ne necessary values for the join properties.

7. (Optional) Use the proposed join cardinality.

The tool analyses the data of tables participating in the join and proposes an optimal cardinality that you can use while
de ning the join properties.

a. In the General Properties section, choose (Propose Cardinality) next to the Cardinality dropdown list.

The tool can propose an optimal cardinality. Choose Yes to use the proposed cardinality.

 Note
Choosing a valid cardinality for your data sources is necessary to avoid incorrect results from the engine, and to
attain better performance. Provide any cardinality value only if you are aware of the optimal cardinality for your
join.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 18/74
1/10/2020
8. Choose OK.

9. (Optional) De ne multi join properties.

The tool supports creating joins between several data sources within a single join view node. If you are creating multiple
join de nitions (multi join), specify the central table and the order in which the tool must execute the join condition.

a. In the view editor, select a data source in the join view node and expand the Properties pane.

b. In the Multi Join Order dropdown list, select the required order.

By default, the join order is Outside In. It implies that the join condition is executed from the outside to the inside
with the central table as the reference (ending with the central table). If you set the join order as Inside Out, the tool
executes the join condition from the inside to the outside (starting from the central table).

c. In the Central Table dropdown list, select the required data source that you want to use a central table in the join
execution.

10. (Optional) De ne calculated columns.

a. Choose the Calculated Columns tab.

b. Choose + (Add).

c. Select and expand the new calculated column.

d. De ne the calculated column.

11. (Optional) De ne input parameters or variables.

a. Choose the Parameters tab.

b. Choose (Add).

c. Select Input Parameter or Variable menu option.

d. Select and expand the new input parameter or variable.

e. De ne the input parameter or variable.

12. (Optional) Filter output of join view node.

Apply lters on output columns of the join view node to lter the output results.

a. Choose the Filter Expression tab.

b. In the Language dropdown list, select the required language.

c. In the expression editor, enter the expression that de nes the required lter conditions.

Use the elements, functions, and operators in the Filter Expression tab to build your expression.

For example,

(revenue >= 100 AND region = India) OR (revenue >=50 AND region = Germany)

13. Add result as inputs to other view nodes.

a. In the view editor, select the join view node.

b. Choose .

c. Drag the cursor to the view node for which you want to provide the input.

Related Information
Create Temporal Joins
Create Spatial Joins
Text Joins
Dynamic Joins
Optimize Join Execution

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 19/74
1/10/2020
Join Properties
Supported Join Types
Create Calculated Columns
Create Input Parameters

Create Non Equi Joins


Use the non equi join view nodes to create join conditions with various comparisions or unequal operators (<, >=, !=, ...) on several
columns.

Context
A non equi join uses comparison operators like !=, >, <, >= and <= to query data from two data sources. Like a normal join, it
allows you to specify the cardinality and a join type (Inner, Left Outer, Right Outer) to query data from two data sources. If multiple
pairs of left and right columns are participating in join de nition, each pair can have different operator.

 Restriction
You can add only two data sources in non equi jon view nodes and cannot create non equi joins between fact table and shared
dimensions.

Procedure
1. Open the required calculation view in the view editor.

2. From the tool palette of the editor, drag a non equi join view node to the editor.

3. Add data sources.

a. Select the non equi join view node.

b. Choose (Add Data Source).

c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.

d. Choose Finish.

4. (Optional) Create constants.

You can create constant values in any of the data source and use them in the join de nition. Creating constant helps, for
example, when you want to de ne a join condition by comparing a column value with a constant value.

a. Choose the Join De nition tab.

b. Select the data source in which you want to create the constant value.

c. In the menu bar, choose +.

d. Provide the required constant value.

e. Choose OK.

5. De ne output columns.

a. In the editor toolbar, choose (Expand Details Panel).

b. On the Mapping tab, select the columns you want to add to the output of the non equi join view node.

c. In the context menu, choose Add To Output.

 Note
If you want to add all columns of a data source to the output, in the context menu of the data source, choose Add
To Output.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 20/74
1/10/2020
6. Create a join.

a. Choose the Join De nition tab.

b. Choose (Create Join).

c. Create a join by selecting the required column from the left table, and dragging the cursor to the required column in
the right table.

d. (Optional) If you want to swap the left tables and right tables, then in the Join Creation dialog box, choose
(Swap Table).

7. De ne non equi join properties.

a. In the Join Creation dialog box, expand the Non Equi Join Properties section.

b. De ne necessary values for the join properties.

 Restriction
For non equi joins, you cannot create temporal joins, text joins, referential joins, dynamic joins.

c. In the Operator dropdown list, select the required operator.

If multiple pairs of left and right columns are participating in join de nition, each pair can have different operator.

 Caution
In non equi join view nodes, using the EQ operator in the join condition may impact the performance of the join
execution. To de ne join conditions with EQ operator, we recommend you to use the normal join view node (equi
join).

8. (Optional) Using the proposed join cardinality.

The tool analyses the data of tables participating in the join and proposes an optimal cardinality that you can use while
de ning the join properties.

a. In the Non Equi Join Properties section, choose (Propose Cardinality) next to the Cardinality dropdown list.

The tool can propose an optimal cardinality. Choose Yes to use the proposed cardinality.

 Note
Choosing a valid cardinality for your data sources is necessary to avoid incorrect results from the engine, and to
attain better performance. Provide any cardinality value only if you are aware of the optimal cardinality for your
join.

9. Choose OK.

10. (Optional) De ne calculated columns.

a. Choose the Calculated Columns tab.

b. Choose + (Add).

c. Select and expand the new calculated column.

d. De ne the calculated column.

11. (Optional) De ne input parameters or variables.

a. Choose the Parameters tab.

b. Choose (Add).

c. Select Input Parameter or Variable menu option.

d. Select and expand the new input parameter or variable.

e. De ne the input parameter or variable.

12. Add result as inputs to other view nodes.

a. In the view editor, select the non equi join view node.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 21/74
1/10/2020

b. Choose .

c. Drag the cursor to the view node for which you want to provide the input.

 Note
You cannot create calculated columns or any lter expressions in non equi join view nodes.

Create Temporal Joins


Temporal joins let you create join between the transaction data (fact table) and the master data. These joins help query data
within a temporal interval.

Context
In the join conditons for temporal columns, apart from the join columns, you can specify the temporal column from fact table and
temporal interval from dimension table.

Procedure
1. Open the calculation view in the view editor.

2. Select the Star Join node.

You can create temporal joins in the star join node only. The star join node must contain a calculation view with a
Dimension data category type as the data source, and the input to the star join node must provide the central fact table.

3. Add data sources.

a. Select the join view node.

b. Choose (Add Data Source).

c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.

d. Choose Finish.

4. De ne output columns.

a. In the editor toolbar, choose (Expand Details Panel).

b. On the Mapping tab, select the columns you want to add to the output of the join view node.

c. In the context menu, choose Add To Output.

 Note
If you want to add all columns of a data source to the output, in the context menu of the data source, choose Add
To Output.

5. Create a join.

Create a join by dragging a column from the shared calculation view (master table) to a column in the other data source
(fact table).

a. Choose the Join De nition tab.

b. Choose (Create Join)

c. Create a join by selecting the required column from the left table, and dragging the cursor to the required column in
the right table.

d. (Optional) If you want to swap the left tables and right tables, then in the Join Creation dialog box, choose
(Swap Table).
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 22/74
1/10/2020
6. De ne the temporal column and the temporal conditions.

In the Temporal Properties section, provide values to create the temporal join.

a. In the Temporal Column dropdown list, select a time column in the calculation view.

b. In the Temporal Condition dropdown list, select a temporal condition.

c. In the From Column and To Column dropdown lists, specify the start and end time values from the calculation view
to fetch the records.

7. Choose OK.

Related Information
Temporal Joins
Temporal Conditions
Example: Temporal Joins

Temporal Joins
A temporal join lets you set time intervals for which you want to fetch records. It indicates the time interval mapping between the
master data and the transaction data.

Temporal joins are based on the date and time eld from the fact table, and the time interval (to and from elds) from the master
data view. The date eld from the fact table is called temporal column.

If the temporal column values in the fact table are within the valid time interval values from the master data view that means the
tables are joined. A time interval is assigned to each record in the results set. These records are valid for the duration of the
interval to which they are assigned.

The supported data types for Temporal Column, From Column, and To Column are timestamp, date, time, and integers only.

Temporal Conditions
Temporal condition values, which you de ne in temporal joins, help determine whether to include or exclude the boundary values.

The boundary values of the time interval is de ned by the FROM and TO date elds of the master data view, while executing the
join condition. The following table lists the temporal conditions.

Temporal Condition Meaning

Include To Exclude From This temporal condition includes the value of the To Column eld and excludes the value of the
From Column eld while executing the join.

Exclude To Include From This temporal condition excludes the value of the To Column eld and includes the value of the
From Column eld while executing the join.

Exclude Both This temporal condition excludes the value from both the To Column eld and the From Column
eld while executing the join.

Include Both This temporal condition includes the value from both the To Column eld and From Column eld
while executing the join.

Example: Temporal Joins


https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 23/74
1/10/2020
Create temporal joins to join the master data with the transaction data (fact table), based on a time column value from the
transaction data and the time validity columns from the master data.

Consider a dimension calculation view named PRODUCT (master data) with attributes PRODUCT_ID, VALID_FROM_DATE, and
VALID_TO_DATE and a calculation view of type cube, SALES (transactional data) with attributes PRODUCT_ID, DATE, and
REVENUE.

Now, you can create a temporal join between the master data view and transaction data using the attribute PRODUCT_ID to
analyze sales of the product for a particular period.

Create Spatial Joins


Create spatial joins to query data from data sources that have spatial data.

Context
You use the join view node in a calculation view to create spatial joins, and create them by joining two database tables on columns
of spatial data types.

Procedure
1. Open the required calculation view in the view editor.

2. From the tool palette of the editor, drag a join view node to the editor.

3. Add data sources.

a. Select the join view node.

b. Choose (Add Data Source).

c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.

d. Choose Finish.

4. De ne output columns.

a. In the editor toolbar, choose (Expand Details Panel).

b. On the Mapping tab, select the columns you want to add to the output of the join view node.

c. In the context menu, choose Add To Output.

 Note
If you want to add all columns of a data source to the output, in the context menu of the data source, choose Add
To Output.

5. Create a join.

Create a join by dragging a column from the shared calculation view (master table) to a column in the other data source
(fact table).

a. Choose the Join De nition tab.

b. Choose (Create Join)

c. Create a join by selecting the required column from the left table, and dragging the cursor to the required column in
the right table.

d. (Optional) If you want to swap the left tables and right tables, then in the Join Creation dialog box, choose
(Swap Table).

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 24/74
1/10/2020
6. De ne spatial join properties.

In the Spatial Join section, de ne the necessary spatial join properties.

a. In the Predicates dropdown list, select a predicate value.

Spatial predicates are conditions that return Boolean results. They serve as join conditions for spatial joins.

 Note
If you select Relate as the predicate value, in the Intersection Matrix text eld enter the required values.
Similarly, if you select Within Distance as the predicate value, in the Distance eld, select a value. You can
provide the distance as a xed value or use an input parameter to provide the distance value at runtime.

b. If you want to execute the spatial join only if the predicate condition evaluates to true, in the Execute Join If
dropdown list, select Predicate Evaluates to True.

7. Choose OK.

Related Information
Supported Spatial Predicates
Supported Spatial Data Types

Supported Spatial Predicates


The following spatial predicates are supported.

Method Type Description

ST_Contains ST_Geometry Tests if a geometry value spatially contains


another geometry value.

ST_CoveredBy ST_Geometry Tests if a geometry value is spatially covered


by another geometry value.

ST_Covers ST_Geometry Tests if a geometry value spatially covers


another geometry value.

ST_Crosses ST_Geometry Tests if a geometry value crosses another


geometry value.

ST_Disjoint ST_Geometry Test if a geometry value is spatially disjoint


from another value.

ST_Equals ST_Geometry Tests if a ST_Geometry value is spatially


equal to another ST_Geometry value.

ST_Intersects ST_Geometry Test if a geometry value spatially intersects


another value.

ST_Overlaps ST_Geometry Tests if a geometry value overlaps another


geometry value.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 25/74
1/10/2020

Method Type Description

ST_Relate ST_Geometry Tests if a geometry value is spatially related


to another geometry value as speci ed by
the intersection matrix. The ST_Relate
method uses a 9-character string from the
Dimensionally Extended 9 Intersection
Model (DE-9IM) to describe the pair-wise
relationship between two spatial data items.
For example, the ST_Relate method
determines if an intersection occurs
between the geometries, and the geometry
of the resulting intersection, if it exists.

ST_Touches ST_Geometry Tests if a geometry value spatially touches


another geometry value.

ST_Within ST_Geometry Tests if a geometry value is spatially


contained within another geometry value.

ST_WithinDistance ST_Geometry Test if two geometries are within a speci ed


distance of each other.

Supported Spatial Data Types


The following spatial data types are supported in data models and query language for storing and accessing geospatial data.

Data Type Description

Geometries The term geometry means the overarching type for objects such as points, linestrings, and polygons.
The geometry type is the supertype for all supported spatial data types.

Points A point de nes a single location in space. A point geometry does not have length or area. A point
always has an X and Y coordinate.
ST_Dimension returns 0 for non-empty points.

In GIS data, points are typically used to represent locations such as addresses, or geographic features
such as a mountain.

Multipoints A multipoint is a collection of individual points.


In GIS data, multipoints are typically used to represent a set of locations.

Linestrings A linestring is geometry with a length, but without any area. ST_Dimension returns 1 for non-empty
linestrings. Linestrings can be characterized by whether they are simple or not simple, closed or not
closed. Simple means a linestring that does not cross itself. Closed means a linestring that starts and
ends at the same point. For example, a ring is an example of simple, closed linestring.

In GIS data, linestrings are typically used to represent rivers, roads, or delivery routes.

Multilinestring A multilinestring is a collection of linestrings.

In GIS data, multilinestrings are frequently used to represent geographic features like rivers or a
highway network.

Polygons A polygon de nes a region of space. A polygon constructed from one exterior bounding ring de nes
the outside of the region and zero or more interior rings, which de ne holes in the region. A polygon
has an associated area but no length.

ST_Dimension returns 2 for non-empty polygons.

In GIS data, polygons are typically used to represent territories (countries, towns, states, and more),
lakes, and large geographic features such as parks.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 26/74
1/10/2020

Data Type Description

Multipolygons A multipolygon is a collection of zero or more polygons.

In GIS data, multipolygons are frequently used to represent territories made up of multiple regions (for
example a state with islands), or geographic features such as a system of lakes.

Text Joins
A text join helps obtain language-speci c data. It retrieves columns from a text table based on the session language of the user.

The text tables contain description for a column value in different languages. For example, consider a PRODUCT table that
contains PRODCUT_ID and a text table PRODUCT_TEXT that contains the columns PRODUCT_ID, DESCRIPTION, and
LANGUAGE.

PRODUCT

PRODUCT_ID SALES

1 1000

2 2000

3 4000

PRODUCT_TEXT

PRODUCT_ID LANGUAGE DESC

1 E Description in English.

1 D Description in German.

2 E Description in English.

3 E Description in English.

Create a text join to join the two tables and retrieve language-speci c data using the language column LANGUAGE. For example, if
your session language is E and if you have added all columns to the output of the join view node, the output of the text join is:

PRODUCT_ID LANGUAGE DESC SALES

1 E Description in English. 1000

2 E Description in English. 2000

3 E Description in English. 4000

 Note
For text joins, always add the text table as the right table.

When you execute a query, the engine evaluates the language setting of your connection. The texts are selected based on the
language setting.

You can set the language when you add a container in the SAP HANA database explorer. If you want to see the English language
being selected, then when adding a container, in the Advanced Options, specify LOCALE=en.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 27/74
1/10/2020
You can further specify the language like en_US. For more information, see 2364550 .

Dynamic Joins
After creating a join between two data sources, you can de ne the join property as dynamic. Dynamic joins helps improve the join
execution process by reducing the number of records processed by the join view node at runtime.

Dynamic joins are special type of joins. In this join type, two or more elds from two data sources are joined using a join condition
that changes dynamically based on the elds requested by the client. For example –Table1 and Table2 are joined on Field1 and
Field2. But, if only one, Field1 or Field2 is requested by a client, the tables (Table1 and Table2) are joined based only on the
requested eld (Field1 or Field2).

 Note
You can set the Dynamic Join property only if the two data sources are joined on multiple columns.

Dynamic join behavior is different from the classical join behavior. In the classical join, the join condition is static. This means that,
the join condition does not change irrespective of the client query. The difference in behavior can result in different query result
sets. Use dynamic joins with caution.

Prerequisite
At least one of the elds involved in the join condition is part of the client query. If you de ne a join as dynamic, the engine
dynamically de nes the join elds based on the elds requested by the client query. But, if the eld is not part of the client query, it
results in query runtime error.

Static Join Versus Dynamic Joins


In static joins, the join condition isn't changed, irrespective of the client query.

In a dynamic join, if the client query to the join doesn't request a join column, a query runtime error occurs. This behavior of
dynamic join is different from the static joins.

Dynamic join enforces aggregation before executing the join, but for static joins the aggregation happens after the join.
This means that, for dynamic joins, if a join column is not requested by the client query, its value is rst aggregated, and
later the join condition is executed based on columns requested in the client query.

Related Information
Example: Dynamic Joins

Example: Dynamic Joins


Consider that you want to evaluate the sales of a product and also calculate the sales share of each product using the following
data sources.

SALES

REGION COUNTRY SALES

APJ IND 10

APJ IND 10

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 28/74
1/10/2020

REGION COUNTRY SALES

APJ CHN 20

APJ CHN 50

EUR DE 50

EUR DE 100

EUR UK 20

EUR UK 30

PRODUCT

REGION COUNTRY PRODUCT

APJ IND PROD1

APJ IND PROD2

APJ CHN PROD1

APJ CHN PROD2

EUR DE PROD1

EUR DE PROD2

EUR UK PROD1

EUR UK PROD2

So you use a calculation view to join the above two data sources via two different aggregation view nodes as inputs to the join view
node. The aggregation view node with the data source SALES does not has the PRODUCT column but contains total sales for a
given region or country.

Now assume that the two aggregation view nodes join dynamically on the columns, REGION and COUNTRY. The outputs of the join
view node are columns REGION, PRODUCT, SALES and the calculated columns, TOT_SALES, and SALES_SHARE.

When you execute a client query on the calculation view to calculate the sales share of a product at a region level, the output from
the dynamic join and static join is different:

Dynamic Join

REGION PRODUCT SALES TOT_SALES SALES_SHARE

APJ PROD1 30 90 .33

APJ PROD2 60 90 .66

EUR PROD1 70 200 .35

EUR PROD2 130 200 .65

Static Join

REGION PRODUCT SALES TOT_SALES SALES_SHARE

APJ PROD1 30 90 .78

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 29/74
1/10/2020

REGION PRODUCT SALES TOT_SALES SALES_SHARE

APJ PROD2 60 90 1.21

EUR PROD1 70 200 .73

EUR PROD2 130 200 1.26

The dynamic join calculates the sales share at the region level by aggregating the sales values before joining the data sources. The
static join, on the other hand, rst calculates the sales share at the region level and the country level (because the join condition
contains both region and country), and then aggregates the resulting sales share after the join is executed.

Optimize Join Execution


While executing the join, by default, the query retrieves join columns from the database even if you don't specify it in the query.
The query automatically includes the join columns into the SQL GROUP BY clause without you selecting them in the query.

You can avoid this default behavior by using the join property Optimizing Join Columns. When this property for a join is set to
True, only the columns speci ed in the query are retrieved from the database.

 Note
Optimizing join columns is supported only for left outer joins with cardinality 1:1 or N:1, text joins with cardinality 1:1 or N:1, right
outer joins with cardinality 1:1 or 1:N, and referential joins.

If the lters are de ned on join columns for which you have enabled Optimize Join Columns, the join optimizer cannot remove
attributes of static lters. In this case, you can optimize the join column by introducing a dummy projection view node between the
join and the input node with static lters.

 Note
Optimize join columns are not supported for non equi joins.

Prerequisites
The join eld is not requested in the query

Only elds from one join partner are requested in the query.

The join is an outer join, referential, or text join.

The cardinality to the join partner from which no elds are requested is set to 1.

Scenario: Using the Optimizing Join Columns Property


Consider a scenario in which a query requests only elds from one join partner, the cardinality to the other partner (of which no
elds are requested) is set to 1, and the join is not an inner join. In such scenarios, the join execution does not in uence the result
set. You can use the optimize join columns property to prune the elds that are not requested in the query.

In general, for scenarios that have multiple join partners on different join elds, if the query requests elds from only a small
subset of join partners, you can use the optimize join columns property to omit various join elds from the aggregation. This ag
helps to explicitly state to the join optimizer to not include the join elds in the aggregation. Omitting the join elds help reduce the
number of records processed by the join optimizer.

This optimization therefore results in a better performance and lower memory consumption. The extent of optimization depends
on the elds that the query request at runtime, and on which elds you have de ned the join.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 30/74
1/10/2020

 Remember
Using a wrong cardinality impacts the result set.

Join Properties
After creating a join, de ne its properties to obtain a desired output when you execute the join.

The tool lets you to de ne the following join properties.

Join
Properties Description

Join Type The value of this property speci es the join type used for creating a join. For more information, see Supported Join Types.

Cardinality The value of this property speci es the cardinality used for creating a join.

By default, the cardinality of the join is empty. If you are uncertain about the right cardinality for the join tables, we
recommend you to not specify any cardinality. The system determines the cardinality when executing the join.

Language The value of this property speci es the language column that the tool must use for executing text joins. For more
Column information, see Text Joins.

Dynamic The value of this property determines whether the tool must dynamically de ne the columns of the join condition based on
Join the client query. For more information, see Dynamic Joins.

Optimize The value of this property determines whether the tool must retrieve the columns that are not speci ed in the query from the
Join database. For more information, see Optimize Join Execution.
Columns

Supported Join Types


When creating a join between two data sources (tables or column views) in a join view node, you specify the join type. The table
shows the supported join types in a join view node.

Join Type Description

Inner Returns all rows when there is at least one match in both the data sources.

Left Outer Returns all rows from the left data source, and the matched rows from the right data source.

Right Outer Returns all rows from the right data source, and the matched rows from the left data source.

Text Join This join type is used to obtain language-speci c data from the text tables using a language column.

Full Outer Displays results from both left and right outer joins and returns all (matched or unmatched) rows
from the tables on both sides of the join clause.

Referential This join type is similar to inner join type, but assumes that referential integrity is maintained for the
join tables.

Optimizing Referential Joins

You can optimize the performance of referential joins by additionally specifying the join direction. The join direction provides more
information to the optimizer on the direction of referential integrity, which helps prune tables participating in the join condition.

The following are prerequisites to optimize referential joins.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 31/74
1/10/2020
The join type is Referential.

The query on the calculation view does not request any elds from the to-be-pruned table.

The join cardinality is set to “..1” or "1.." based on the join direction for the to-be-pruned table.

The tool supports the following as the join directions for referential joins.

Direction Description

Left It is the default join direction and implies that the referential integrity is provided by the left
table.

Right Referential integrity is provided by the right table.

Both The optimizer evaluates both the tables in the join condition.

Create Unions
Use union view nodes in calculation views to combine the results of two or more data sources.

Context
A union view node combines multiple data sources. These data sources can have multiple columns. You can manage the output
column of a union view node by:

Mapping the source columns to the output columns or

Create a target output column with constant values and map the source columns with the constant values.

For source columns, which do not have mappings to any of the output columns, create a target output column and map it to the
unmapped source columns.

Procedure
1. Open the required calculation view in the view editor.

2. From the tool palette of the editor, drag and drop a union view node to the editor.

3. Add data sources.

a. Select the union view node.

b. Choose

c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list. (Add Data
Source).

d. Choose Finish.

4. De ne output columns.

a. In the editor toolbar, choose (Expand Details Panel).

b. On the Mapping (Add pane, select the columns you want to add to the output of the union view node.

c. In the context menu, choose Add To Output.

 Note
If you want to add all columns from the data source to the output, in the context menu of the data source,
choose Add To Output.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 32/74
1/10/2020

5. (Optional) Create constant output columns.

Create new output columns and assign it with constant values.

a. Choose the Mappings tab.

b. In the Output Columns section, choose + (Create Constant).

c. In the Create Target and Manage Mapping dialog box, provide a name for the new constant output column.

d. Provide the required data type, length, and scale values.

e. In the Source Column dropdown list, select the required column from the data source with which you want to map
the constant output column.

f. In the Constant Value text eld, provide the required constant value.

g. Select is Null checkbox, if you want to assign a null value to the constant output column.

 Note
If you do not provide any constant value, then the tool, by default, considers the constant output column value
as null.

h. Choose OK.

6. (Optional) De ne calculated columns.

a. Choose the Calculated Columns tab.

b. Choose + (Add).

c. Select and expand the new calculated column.

d. De ne the calculated column.

7. (Optional) De ne input parameters or variables.

a. Choose the Parameters tab.

b. Choose (Add).

c. Select Input Parameter or Variable menu option.

d. Select and expand the new input parameter or variable.

e. De ne the input parameter or variable.

8. Add result as inputs to other view nodes.

a. In the view editor, select the union view node.

b. Choose .

c. Drag the cursor to the view node for which you want to provide the input.

Related Information
Example: Constant Columns
Empty Union Behavior
Prune Data in Union Nodes
Create Calculated Columns
Assign Variables
Create Input Parameters

Data Types of Output Columns in Union View


Node
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 33/74
1/10/2020
In Union view nodes, columns of different data sources can be mapped to the same output column. The tool determines the data
type of the output columns based on certain rules.

The data type of the input column is determined by the data type of the column in the source. Therefore, it typically corresponds
to the data type of the column in a source table. The data type of the output column is determined by the below rules.

As a general rule, avoid implicit castings of input columns. Instead, map input columns of the same data type with the same
output column. Nevertheless, if columns of some speci c data types are mapped, implicit casting happens. Below is a list of the
data types for which implicit casting happens.

In the following, we refer to data types NVARCHAR, VARCHAR and SHORTTEXT with the term “string_type” and to data types
TINY, SMALL, INTEGER with the term “integer_type”.

In the list below “ x <-> y “ means that implicit casting happen between data type x and data type y.

Implicit casts happen:

within integer_type: TINY <-> SMALL <-> INTEGER

within string_types: NVARCHAR <-> VARCHAR <-> SHORTTEXT

DATE <-> TIMESTAMP <-> string_type

VARBINARY <-> string_type

 Note
Do not rely on implicit casting between other data types. In future releases we will open up implicit castings between additional
data types and list this in the documentation and SAP Note 2823865.

Currently, NCLOB, BLOB, LOB are only implicitly casted if they are not used as the rst data source of the UNION node ( “x -> y”
means that implicit casting only happens from data type x to data type y but not the other way around):

string_type -> NCLOB

string_type -> BLOB

string_type -> LOB

string_type -> TEXT

For example, UNION of string_type and NCLOB would work while the reverse order, UNION of NCLOB and string_type, would fail.

Prune Data in Union Nodes


Pruning data in union view nodes help optimize the query execution on the union view node. To prune data, you need a pruning
con guration table that speci es the lter conditions to limit the result set.

Context
You can manually create pruning con guration tables (. hdbcds tables) or use the form-based table editor that the tool provides
to create them. After creating a pruning con guration table, reference it in the target calculation view properties.

 Remember
If the queries executed on the union view node unfolds and does not perform any aggregation, then the tool does not prune
data. In such cases, switch off the unfolding behavior with the hint, NO_CALC_VIEW_UNFOLDING.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 34/74
1/10/2020

Unfolding is the normal query execution behavior in which the query execution is passed to the SQL engine or the optimizer after
the calculation engine instantiates the query. This unfolding behavior is not possible for complex calculation views.

Procedure
1. Open the required calculation view in which you want to de ne the data pruning for its union view nodes.

2. Edit view properties.

a. Select the Semantics node.

b. In the editor toolbar, choose (Expand Details Panel).

c. Choose the View Properties tab.

d. Choose Advanced.

3. If you have already created a pruning con guration table and if you want to use the same for the selected calculation view,
then in the Pruning Con guration Table eld, use the search to nd and add the required table.

 Note
You can use only tables or views as pruning con guration tables.

4. If you want to create a new pruning con guration table, choose +.

a. In the Table Name text eld, enter a name for the pruning con guration table.

b. Choose + to add a lter condition that limits the result set of a union view node.

You can add more than one lter condition in a single pruning con guration table. If you are creating multiple lter
conditions using the same column, then the lter conditions are combined using the logical OR operator. But, if you
are using different columns to provide the lter conditions, then the lter conditions are combined using the logical
AND operator.

c. In the Input eld, use the value help to select a data source in the union view node.

d. In the Column eld, use the value help to select a column from the data source.

e. In the Operators dropdown list, select the required operator to de ne the lter condition.

f. Use the Low and High text elds based on the selected operator to de ne the lter condition.

5. Choose Create and Build.

The tool creates the pruning con guration table and all other les (.hdbcds, .hdbtabledata, and .csv) that are necessary to
prune the data. These les are created in the same SAP HANA Database Module in which you have created the calculation
view.

6. (Optional) Choose (Edit Pruning Con guration) to edit an existing pruning con guration table used for the selected
calculation view.

Related Information
Union Node Pruning
Pruning Con guration Table
Example with a Pruning Con guration Table
Example with a Constant Mapping
Example Tables

Union Node Pruning


Union node pruning allows the data sources in union nodes to be pruned. It is based on de ned criteria that at runtime exclude
speci c data sources from the processing. This helps reduce resource consumption and bene ts performance.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 35/74
1/10/2020
To prune data sources, you need either a pruning con guration table or a constant mapping. If you opt for the con guration table
approach, you use a table to specify data slices contained in the individual data sources. This information is matched to the query
lter when the query is run, and as a result, only the required data sources are processed. With constant mapping, you de ne a
constant with speci c values for each data source and select the appropriate value in your query.

For example, you are creating a sales report for a product across the years using a calculation view. The calculation view consists
of two data sources, one with the current sales data (for YEAR >= 2018) and the other with the archived sales data (YEAR <=
2017). Both are provided as input to a union node in the calculation view, as shown below:

In your scenario, you want to query the calculation view to get the results of CURRENT_SALES only. You therefore want the query
to be executed on the CURRENT_SALES data source only, and the operation on the archived data source to be excluded (that is,
pruned). To do so, you have the following options:

You provide a pruning de nition in a pruning con guration table.

You create a constant that maps the data sources to speci c constant values.

 Note
In general, constant mapping improves performance more but is less exible than using a pruning con guration table.

 Note
If a union node is consumed by a rank node, query lters will, by default, not be pushed down to it when the query is executed.
This applies to lter expressions and variables used in a WHERE clause. However, to be able to apply pruning, the union node
needs the lters. In these cases, therefore, the combination of rank node and union node with pruning only makes sense if the
Allow Filter Push Down option has been activated for the rank node.

Related Information
Pruning Con guration Table
Example with a Pruning Con guration Table
Example with a Constant Mapping
Example Tables
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 36/74
1/10/2020
SAP Note 2752070

Pruning Con guration Table


A pruning de nition in a pruning con guration table has a speci c format.

The format of a pruning con guration table is as follows:

Column Name Description

CALC_SCENARIO Fully quali ed name of the calculation view to which union node pruning is to be
applied. For example, p1.p2::CV_PRUNING, where p1.p2 is the namespace and
CV_PRUNING is the name of the calculation view.

INPUT Name of the data source in the union node of the calculation view.

COLUMN Target column name

OPTION Operator (=, <, >, <=, >=, BETWEEN)

LOW_VALUE Filter condition

HIGH_VALUE Filter condition

To assign a pruning con guration table to a calculation view, select the Semantics node and choose View Properties Advanced .
Note that if you have not already created a pruning con guration table, you can both create and build it from here.

Example with a Pruning Con guration Table


In this example, you use a pruning con guration table to specify the lter conditions for pruning the union node. A matching lter
is then applied in the WHERE clause of the query so that only one of the data sources is processed.

Context
The calculation view is based on the example shown earlier. The Union node is used to combine the two data sources
Current_Sales and Old_Sales. In the procedure below, you query the calculation view to get the current sales results only.

Procedure
1. Create a pruning de nition in a pruning con guration table. For example:

Table: UNION_PRUNING

CALC_SCENARIO INPUT COLUMN OPTION LOW_VALUE HIGH_VALUE

1 p1.p2::CV_PRUNING OldSales YEAR <= 2017 NULL

2 p1.p2::CV_PRUNING CurrentSales YEAR >= 2018 NULL

 Note
You can also create the table within step 3.

2. In the calculation view, select the Semantics node and choose View Properties Advanced .

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 37/74
1/10/2020
3. In the Pruning Con guration Table eld, use the search to nd and add the pruning con guration table created above, or
choose + to create the table. For example:

The calculation view now contains the pruning con guration table with the two data sources CurrentSales and OldSales.

4. Build the calculation view.

5. Execute a query on the calculation view with a lter condition that is the same as the condition de ned in the pruning
con guration table. For example:

SELECT
"SALESORDER",
"PRODUCT",
"YEAR",
SUM("SALES") AS "SALES"
FROM "JOINCARDINALITYEXAMPLE_HDI_DB_1"."p1.p2::CV_PRUNING"
WHERE "YEAR" >= '2018'
GROUP BY "SALESORDER", "PRODUCT", "YEAR";

6. From the Run dropdown menu, choose Analyze SQL.

7. On the Operators tab, lter by the Column Table operator.

As can be seen, only the Current_Sales table is accessed. For example:

This con rms that the union node could be pruned because the lter condition matches the one in the pruning
con guration table.

8. Remove the pruning con guration table from the view properties of the calculation view and build it again.

9. Enter the same query as above and choose Analyze SQL from the Run dropdown menu.

10. On the Operators tab, lter by the Column Table operator.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 38/74
1/10/2020
As can be seen, the query is now invoking both the archived sales data and current sales data, although only the current
sales data is required. For example:

The presence of the Old_Sales table indicates that the union node was not pruned.

Results
As demonstrated therefore, union node pruning in calculation views allows the execution ow to be determined dynamically based
on the query. This allows resource consumption to be reduced and performance improved.

Example with a Constant Mapping


In this example, you use a constant to de ne the criteria for pruning the union node and then apply it in the WHERE clause of the
query.

Context
The calculation view is based on the example shown earlier. The Union node is used to combine the two data sources
Current_Sales and Old_Sales. In the procedure below, you use the debug feature to visualize the pruning.

Procedure
1. Create a calculation view with a Union node as follows:

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 39/74
1/10/2020

2. Create a constant to differentiate between the two different data sources:

a. On the Mapping tab of the Union node, choose + (Create Constant) in the Output Columns toolbar.

b. Enter the details required to differentiate between the two data sources. For example:

3. Save and build the calculation view.

4. To start debugging, select the Semantics node and then choose the Debug button.

5. On the Debug Query tab, add the following WHERE clause to the default debug query:

WHERE "SALESYEAR" = 'CURRENT'

For example:

SELECT "SALESORDER",
"PRODUCT",
"YEAR",
SUM("SALES") AS "SALES"
FROM "JOINCARDINALITYEXAMPLE_HDI_DB_1"."p1.p2::UNION_PRUNING"
WHERE "SALESYEAR" = 'CURRENT'
GROUP BY "SALESORDER", "PRODUCT", "YEAR", "SALESYEAR";

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 40/74
1/10/2020
6. Click Execute to run the query.

The Old_Sales data source is now grayed out, indicating that is not being processed. For example:

The reason why it has been excluded is that the SALESYEAR lter does not match the constant value OLD that you de ned
for it.

7. Rerun the debug query but replace CURRENT with OLD.

For example:

SELECT "SALESORDER",
"PRODUCT",
"YEAR",
SUM("SALES") AS "SALES"
FROM "JOINCARDINALITYEXAMPLE_HDI_DB_1"."p1.p2::UNION_PRUNING"
WHERE "SALESYEAR" = 'OLD'
GROUP BY "SALESORDER", "PRODUCT", "YEAR", "SALESYEAR";

This time the Current_Sales data source is grayed out. For example:

Results
As shown above, when a constant is added to the union node of a calculation view, queries that apply a lter on that constant will
prune the applicable data sources in the Union node. This technique can be used to improve the runtimes of complex models.

Example Tables
The following tables are used in the examples.

Current_Sales

SALESORDER PRODUCT YEAR SALES

006 PROD1 2018 450

006 PROD2 2018 330

006 PROD3 2018 510

007 PROD3 2018 1020

007 PROD1 2018 1350

007 PROD2 2018 990

008 PROD1 2018 450

008 PROD2 2018 330

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 41/74
1/10/2020

Current_Sales

SALESORDER PRODUCT YEAR SALES

009 PROD1 2018 900

009 PROD3 2018 1020

Old_Sales

SALESORDER PRODUCT YEAR SALES

001 PROD3 2016 510

001 PROD1 2016 450

001 PROD2 2016 330

002 PROD1 2017 900

002 PROD3 2017 1020

002 PROD2 2017 660

003 PROD3 2017 510

004 PROD1 2017 450

004 PROD3 2017 510

005 PROD2 2017 330

Example: Constant Columns


Constant output columns help denote the underlying data from the source columns with constant values in the output. You can
also map the unmapped source columns to a constant output column based on the business requirement.

For example, consider that you want to compare the planned sales of each quantity with its actual sales using two data sources
with similar structures, ACTUALSALES and PLANNEDSALES.

ACTUALSALES

SALES_QUANTITY PRODUCT_ID

5000 P1

3000 P2

PLANNEDSALES

SALES_QUANTITY PRODUCT_ID

4000 P1

4000 P2

When you use a union view node to combine the results of the two data sources, you cannot differentiate the data from these data
sources.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 42/74
1/10/2020

SALES_QUANTITY PRODUCT_ID

5000 P1

3000 P2

4000 P1

4000 P2

In such cases, create a constant output column PLANNED_OR_ACTUAL and assign the constant value ACTUAL to
ACTUALSALES and the constant value PLANNED to PLANNEDSALES.

SALES_QUANTITY PRODUCT_ID PLANNEDORACTUAL

5000 P1 ACTUAL

3000 P2 ACTUAL

4000 P1 PLANNED

4000 P2 PLANNED

Now, you can identify the data source and its underlying data.

Empty Union Behavior


The Empty Union Behavior property determines whether queries on union view nodes, ones with constant output columns, return
values when no other column from the data source is queried.

This property is useful, for example, for value help queries in applications. You can select either No Row or Row with Constant as
values for the Empty Union Behavior property. Select the data source in the mapping de nition and, in the Properties tab, de ne
the values for this property based on your business requirement.

For understanding the Empty Union Behavior property and how its value determines the output data, consider the following
mapping de nition in a union view node:

Constant values A and B are de ned for Projection_1 and Projection_2 using the constant column, CONSTANT.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 43/74
1/10/2020

When you execute a query on a calculation view with this union view node, and if the column CUSTOMER_ID is not queried, then
the Empty Union Behavior property of Projection_2 determines whether the constant column, CONSTANT returns the constant
value, A for Projection_2 in the output:

If the Empty Union Behavior property is set to No Row, then no data from Projection _2 appears in the output data. Only
data from Projection_1 appears in the output data.

If the Empty Union Behavior property is set to Row with Constant, the output data includes one record from Projection
_2. In this one record, the constant value A appears for the CONSTANT column and values for all other columns appears as
null.

Create Rank Nodes


Use rank nodes in calculation views to perform a logical partition of the data for a set of partition columns, and perform a ORDER
BY SQL operation on the partitioned data.

Context
For example, consider a TRANSACTION table with two columns PRODUCT and SALES. If you want to retrieve the top ve
products based on sales, use a rank node. The rank node rst partitions the TRANSACTION table with the PRODUCT as the
partition column, and performs an order by operation on the partitioned table using the SALES column to retrieve the top ve
products based on sales.

Procedure
1. Open the required calculation view in the view editor.

2. From the tool palette of the editor, drag the rank node to the editor.

3. Add data source.

a. Select the rank node.

b. Choose (Add Data Source).

c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.

d. Choose Finish.

4. De ne output columns.

a. In the editor toolbar, choose (Expand Details Panel).

b. On the Mapping tab, select the columns you want to add to the output of the rank node.

c. In the context menu, choose Add To Output.

 Note

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 44/74
1/10/2020
If you want to add all columns from the data source to the output, in the context menu of the data source,
choose Add To Output.

5. De ne the rank node.

a. Select the De nition tab.

b. In the Aggregation Function dropdown list, select a value.

Supported Aggregation Function for Rank Node

Function Description

Row This aggregation function sequentially numbers the rows


within a partition of a result set, with the rst row of each
partition assigned as 1. The output of this function can be
non-deterministic among tie values.

Rank This aggregation function returns duplicate values in the


ranking sequence when there are ties between values and
the next rankings are skipped.

Dense Rank This aggregation function performs the same ranking


operation as the Rank function, except that rank numbering
does not skip when ties are found.

Sum This aggregation function performs the ranking operation


for records based on the cummilative sum speci ed as a
target value for the sort column. The records are ranked
sequentially until the cummilative sum of the the sort
column records is equal to or lesser that the target value
speci ed.

 Note
The aggregation functions listed here are available with SPS 04 version onwards. If you have created rank nodes
with the earlier version, you can still open the calculation view in the edior and work with the rank view nodes.
But, in such cases you can only use the UI capabilities supported in earlier versions for the rank view node.

For example on the behavior of these functions, see the Related Information section.

c. In the Result Set Direction dropdown list, select a value.

Result Set Direction

Value Description

TOP Retrieves top N records from the ordered set, where N is the
target value speci ed.

DOWN Retrieves bottom N records from the ordered set, where N is


the target value speci ed.

d. In the Result Set Type dropdown list, select a value.

Result set type

Type Description

Absolute If you want to specify the number of records to retrieve from


the ordered set as an absolute value.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 45/74
1/10/2020

Type Description

Percentage If you want to specify the number of records to retrieve from


the ordered set as a percentage of the actual result set.

e. In the Target Value dropdown list, select a value.

The Target Value helps identify the number of records that the query must retreive to the output of the rank node. If
the target value is N, the query retrieves records from the ordered set with rank up to N. You can specify the target
value as a xed value or use an input parameter to provide the value at runtime.

f. In the Offset dropdown list, select a value.

The value helps offset or skip records with rank up to M from the ordered set to the output of the rank node, where
M is the offset value that you specify. You can provide the offset value as a xed value or use an input parameter to
provide values at runtime.

6. Generate a rank column.

If you want to generate an additional output column in the rank node to store the rank values, select the Generate Rank
Column checkbox.

7. Partition the data.

The rank node enables you to perform logical partition of the ordered set using one or more partition columns.

a. In the Logical Partition section, choose + (Add).

b. In the Column dropdown list, select a column that the tool must use to partition the data.

8. (Optional) Select the Dynamic Partition Elements checkbox.

Select to partition the data with only partition by columns that the query requests for processing the rank node.

 Note
In the converse, without dynamic partition, the tool partitions the data with all partition by columns in the Partition By
section, even if these columns are not requested in the query.

9. De ne ORDER BY columns and sort direction.

You can use one or more columns to ORDER BY and de ne the sort direction to order records in each partition.

a. In the Sort Column section, choose + to add one or mode columns as the ORDER BY columns.

b. In the Sort Direction dropdown list, select a sort direction.

Sort Direction Description

Descending Sort records in each partition in descending


order.

Ascending Sort records in each partition in ascending order.

10. (Optional) De ne input parameters or variables.

a. Choose the Parameters tab.

b. Choose (Add).

c. Select Input Parameter or Variable menu option.

d. Select and expand the new input parameter or variable.

e. De ne the input parameter or variable.

11. Add result as inputs to other view nodes.

a. In the view editor, select the rank node.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 46/74
1/10/2020

b. Choose .

c. Drag the cursor to the view node for which you want to provide the input.

Related Information
Assign Variables
Create Input Parameters

Create Graph Nodes


Using graph view nodes in calculation views enable you to use any of the supported SAP HANA Graph actions on a graph
workspace.

Prerequisites
You have at least one vertex table, one edge table, and one graph workspace, in the same SAP HANA Database Module as the
calculation view.

Context
Graphs are a powerful abstraction that can be used to model different kinds of networks and linked data coming from many areas,
such as logistics and transportation, utility networks, knowledge representation, text processing, and more. SAP HANA Graph is
an integral part of SAP HANA core functionality. It expands the SAP HANA platform with native support for graph processing and
allows you to execute typical graph operations on the data stored in an SAP HANA system.

Procedure
1. Open the required calculation view in the view editor.

2. From the tool palette of the editor, drag a graph node to the editor.

 Note
You can add graph nodes in calculation views as leaf nodes only.

3. Add data sources.

a. Select the graph view node.

b. Choose (Add Data Source).

c. In the Find Data Sources you have at least one vertex table, one edge table, and one graph workspace, in the same
HDB dialog box, enter the name of a graph workspace and select it from the list.

 Note
You can add only a graph workspace as the data source in graph view nodes. An SAP HANA Database Module
can have multiple graph workspaces, vertex tables, or edge tables.

d. Choose Finish.

4. Select an action.

Select a supported action (a graph operation or algorithm) that you want to execute on the graph workspace.

a. In the editor toolbar, choose (Expand Details Panel).

b. In the Action tab, choose (Change Algorithm).

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 47/74
1/10/2020
c. Select the required action.

5. De ne the parameters necessary to execute the action.

After selecting an action, de ne values for all parameters that are necessary to execute the action. You can also create and
use input parameters to provide values.

For pattern matching, you can use the graphical editor to visually compose the pattern. The pattern comprises of vertices
connected by edges. Use the + (Add Vertex) icon in the menu bar to add a vertex to the editor and drag the cursor from one
vertex to the other to create an edge. After composing your pattern, de ne conditions on the vertex. In the Mapping tab,
de ne the output columns.

For pattern matching with cypher editor, write the required pattern matching query using the supported subset of the
Cypher query language on the given graph workspace. After writing the query, choose Generate Column to create the
output columns.

6. View output columns.

The output columns of a graph node vary depending on the action you select.

a. Select the Columns tab to view output columns of the graph node.

7. Create input parameters, if required.

a. Select the Parameters tab and create a new input parameter. You can create input parameters to parameterize the
execution of graph node and provide values at runtime to execute the graph node.

You can use this input parameter while de ning the parameters necessary to execute a selected action.

8. Add the results as input to other view nodes.

You can add the output of graph view nodes as inputs (to data source) to multiple view nodes at the same time. If you are
using Shortest Path action in your graph view node, you can optionally add the output edge table from the graph view node
as inputs to other view nodes. Select the graph node and choose (Edge Output) to add the edge table as an input to a
view node.

Related Information
SAP HANA Graph Model
Graph Workspaces
Supported Graph Actions in Calculation Views

SAP HANA Graph Model


SAP HANA Graph is an integral part of SAP HANA core functionality. It expands the SAP HANA platform with native support for
graph processing and allows executing typical graph operations on the data stored in an SAP HANA system.

The SAP HANA Graph model provides basic information for creating graphs to depict data relationships visually. It allows typical
graph operations to be run on the data stored in an SAP HANA system.

Graphs are powerful abstraction that can be used to model different kinds of networks and linked data coming from many areas,
such as logistics and transportation, utility networks, knowledge representation, text processing, and more.

In SAP HANA, a graph is as a set of vertices and edges. Each edge connects two vertices; one vertex is denoted as the source and
the other as the target. Edges are always directed and there can be two or more edges connecting the same two vertices. Vertices
and edges can have an arbitrary number of attributes. Both vertices and edge attributes consists of a name, which is associated
with a data type and a value. Edge attributes consist of the same information.

For more information about the SAP HANA Graph model, see SAP HANA Graph Reference Guide.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 48/74
1/10/2020

Graph Workspaces
A graph workspace is an object in the database that de nes a graph that consists of tables and columns.

A graph workspace includes the following:

Vertex table

Edge table

Key column in the vertex table

Key column in the edge table

Source in the edge table

Target in the edge table

 Note
You can use CDS tables or SQL syntax to create vertex tables and edge tables. For more information on how to create
vertex tables and edge tables, see the SAP HANA Graph Reference guide.

Example Artifact Code

The following code shows a simple example of a graph workspace de nition for XS advanced HDI:

 Code Syntax
/src/my_graph_workspace.hdbgraphworkspace

GRAPH WORKSPACE MY_GRAPH_WORKSPACE


EDGE TABLE THE_EDGE_TABLE
SOURCE COLUMN source TARGET COLUMN target KEY COLUMN edge_id
VERTEX TABLE THE_VERTEX_TABLE
KEY COLUMN vertex_id

Plug-in Con guration

In the con guration le for the HDI container (.hdiconfig), the plug-in con guration should look like the following example:

 Code Syntax
.hdiconfig

"hdbgraphworkspace" : {
"plugin_name" : "com.sap.hana.di.graphworkspace",
"plugin_version": " "
}

Supported Graph Actions in Calculation


Views
You can use the graph view node to execute any of the supported SAP HANA Graph actions on a graph workspace.

The following table lists the supported graph actions that you can execute using the graph view node in a calculation view.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 49/74
1/10/2020

Action Description

Neighborhood Retrieves the neighboring vertices within the given radius (depth) from the given start vertices.

Shortest Path (One-to-All) Provides the information for the shortest path from the starting vertex to all reachable
vertices.

Shorted Path (One-to-One) Returns the shortest path from the provided start vertex to the provided target vertex.

Strongly Connected Components Calculates strongly connected components (SCC) in the given graph workspace.

Pattern Matching Identi es all the subgraphs (within a graph) that match the given pattern.

Related Information
Neighborhood
Shortest Path (One-to-All)
Shortest Path (One-to-One)
Strongly Connected Components
Pattern Matching

Neighborhood
The Neighborhood graph action retrieves the neighboring vertices within the given radius (depth) from the start vertices.

This action lets you specify multiple start vertices, choose a traversal direction, set lters on vertices and edges, and set minimum
and maximum depth (radius) of the neighborhood.

This action has the following additional parameters:

Parameter Value

Start Vertices Set of start vertex keys.

Direction Traversal direction, can use one of the following values: any, incoming, and outgoing (default:
outgoing).

Minimum Depth Minimum depth (radius) of the neighborhood. 0 means that the start vertices are included in the
result.

Maximum Depth Maximum depth (radius) of the neighborhood.

Vertex Filter Vertex lter expression analogous to SQL where-clause on the vertex table (default: empty).

Edge Filter Edge lter expression analogous to SQL where-clause on the edge table (default: empty).

The output includes the following:

Output Column Description

Vertex Table Primary Key Contains the set of explored vertices with vertex table primary key.

Depth The depth level of the neighborhood.

Shortest Path (One-to-All)


https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 50/74
1/10/2020
This action provides information for the shortest path from the starting vertex to all reachable vertices.

Shortest Path action returns the shortest paths from the provided start vertex to all reachable vertices in the graph also known as
single-source shortest path (SSSP). The resulting shortest paths form a tree structure with the start vertex at the root. All other
vertices carry the shortest distance (smallest weight) information. The non-negative edge weights are read from the column
provided in the edge table.

This action has the following additional parameters:

Parameter Value

Start Vertex Start vertex key

Weight Column A column in the edge table that contains edge weights. If omitted, edge weights are set to
1.

Direction Traversal direction, can use one of the following values: any, incoming, outgoing.

The output includes the following:

Output Columns Description

Vertex table Contains vertex keys and corresponding smallest weights (shortest distances)

Edge table Edge table with shortest paths

Shortest Path (One-to-One)


This action returns the shortest path from the provided start vertex to the provided target vertex - also known as single-source
single-target shortest path (SSSTSP).

The resulting table contains all vertices with the distance to the start vertex that are part of the shortest path between the start
vertex and target vertex.

 Note
Theoretically, there is more than one shortest path between two vertices with the same distance. This algorithm returns one of
them.

The non-negative edge weights are read from the column provided in the edge table.

This action has the following additional parameters:

Parameter Value

Start Vertex Start vertex key

Target Vertex Target vertex key

Weight Column A column in the edge table that contains edge weights. If omitted, edge weights are set to
1.

Direction Traversal direction, can use one of the following values: any, incoming, outgoing.

The output includes the following:

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 51/74
1/10/2020

Output Columns Description

Source Column Name in output table that contains the source of the traversed edge.

Default: source column name of graph workspace

Target Column Edge table with shortest paths

Ordering Name in output table that contains the target of the traversed edge.

Default: target column name of graph workspace

Vertex Table Primary Contains the set of explored vertices with vertex table primary key.
Key

Weight Output weight (shortest distance) column name (default: “WEIGHT”)

Strongly Connected Components


The Strongly Connected Components action calculates strongly connected components (SCC) in the given graph workspace.

Strongly connected components partition the given graph workspace into largest subgraphs possible, where every vertex is
reachable from every other vertex. Knowing strongly connected components is helpful for cycle detection, because, by de nition,
the cycles can only exist within strongly connected components and they cannot cross strongly connected component
boundaries.

The only output of this action is a table containing the vertex key column and a COMPONENT column containing strongly
connected component indexes. All vertices having the same component index belong to the same strongly connected component.

The output includes the following:

Output Column Description

Vertex Table Primary Key Contains the set of explored vertices with vertex table primary key.

Component Component index column name (default: “COMPONENT”)

Pattern Matching
Pattern matching is a kind of graph query, which involves nding all the subgraphs (within a graph) that match the given pattern.

The graphical calculation view editor in the SAP Web IDE provides two approaches to model calculation views with graph nodes
that help execute graph pattern queries. In the rst approach, you can use the graphical pattern matching editor to create and
execute graph pattern queries. In the second approach, describe the pattern in the openCypher query language (Cypher is a
registered trademark of Neo Technology, Inc.) within the graph node and execute them.

Pattern Matching with Graphical Pattern Editor


The graphical pattern editor lets you visually compose pattern matching queries, execute them, and visualize the results.

The graphical pattern contains a set of vertex variables, a set of edge variables, a set of lter conditions, a projection list, an order-
by list, a limit, and an offset.

The result of the graphical pattern matching query is a projection of subgraphs within a given graph workspace that matches the
given pattern. The columns of the result table correspond to the projection list of the given pattern. Every row in the result table

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 52/74
1/10/2020
corresponds to a matching subgraph.

In the editor, choose + to add a new vertex. After adding vertices to the editor, select a vertex and choose to create an

edge.

Pattern Matching with openCypher Query Language


The pattern matching action with the openCypher query language enables you to execute pattern matching queries on the given
graph workspace. You write these queries in the supported subset of the openCypher query language

expression A query string written in the supported subset of the Cypher query
language containing one MATCH clause and one RETURN clause.

The output includes the following:

result table Every row corresponds to a matching subgraph. Every row contains
attributes of vertices and edges speci ed in the RETURN clause.

In the editor, choose Generate Column to de ne the output columns of the graph node. The tool includes the columns in the
RETURN clause as the output columns of the graph node.

 Note
For more information on openCypher Query language, see the SAP HANA Graph Reference guide.

Use Intersect Set Operation


Use the intersect view node in calculation views to perform intersect set operations on two data sources.

Context
Intersect set operations on data sources in calculation views help retrieve rows that are common to both the data sources. The
tool supports performing intersect set operations only for two data sources at a time. After performing the intersect set operation,
you can use the result of the intersect set operation as inputs to other view nodes.

For example, you can perform intersect set operations on SALES_2016 and SALES_2017 to identify the subset of products sold
during both, 2016 and 2017.

 Note
You can perform intersect operation only if both the data sources have same number of elds with matching data types.

Procedure
1. Open the required calculation view in the view editor.

2. From the tool palette of the editor, drag and drop an intersect view node to the editor.

3. Add data sources.

 Note
You must have two data source in the intersect view node.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 53/74
1/10/2020
a. Select the intersect view node.

b. Choose (Add Data Source).

c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.

d. Choose Finish.

4. De ne output columns.

a. In the editor toolbar, choose (Expand Details Panel).

b. On the Mapping tab, select the columns you want to add to the output of the intersect view node.

c. In the context menu, choose Add To Output.

 Note
If you want to add all columns of a data source to the output, in the context menu of the data source, choose Add
To Output.

5. (Optional) Create constant output columns.

Create new output columns and assign it with constant values.

a. Choose the Mapping tab.

b. In the Output Columns section, choose + (Create Constant).

c. In the Create Target and Manage Mapping dialog box, provide a name for the new constant output column.

d. Provide the required data type, length, and scale values.

e. In the Source Column dropdown list, select the required column from the data source with which you want to map
the constant output column.

f. In the Constant Value text eld, provide the required constant value.

g. Select is Null checkbox, if you want to assign a null value to the constant output column.

 Note
If you do not provide any constant value, then the tool, by default, considers the constant output column value
as null.

h. Choose OK.

6. (Optional) De ne calculated columns.

a. Choose the Calculated Columns tab.

b. Choose + (Add).

c. Select and expand the new calculated column.

d. De ne the calculated column.

7. (Optional) De ne input parameters or variables.

a. Choose the Parameters tab.

b. Choose (Add).

c. Select Input Parameter or Variable menu option.

d. Select and expand the new input parameter or variable.

e. De ne the input parameter or variable.

8. Add result as inputs to other view nodes.

a. In the view editor, select the intersect view node.

b. Choose .

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 54/74
1/10/2020
c. Drag the cursor to the view the node for which you want to provide the input.

Related Information
Create Calculated Columns
Assign Variables
Create Input Parameters

Use Minus Set Operation


Use the minus view node in calculation views to perform minus set operations on two data sources.

Context
Minus set operations on data sources help rst retrieve all rows from the rst data source, and then removes all rows that appear
in the result set of the second data source. The tool supports performing minus set operations only for two data sources at a time.
After performing the minus set operation, you can use the result of the set operation as inputs to other view nodes.

For example, you can perform minus set operations on SALES_2017 and SALES_2016 to identify those products that were sold
in 2017, but not in the year 2016.

 Note
The results of the minus set operations are dependent on the order of the data sources in the minus view node, and you can
perform minus operation only if both the data sources have same number of elds with matching data types.

Procedure
1. Open the required calculation view in the view editor.

2. From the tool palette of the editor, drag and drop a minus view node to the editor.

3. Add data sources.

You must have two data source in the minus view node.

a. Select the minus view node.

b. Choose (Add Data Source).

c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.

d. Choose Finish.

If you want to switch the order of the data sources in the node, right-click the minus view node and choose Switch
Order.

4. De ne output columns.

a. In the editor toolbar, choose (Expand Details Panel).

b. On the Mapping tab, select the columns you want to add to the output of the minus view node.

c. In the context menu, choose Add To Output.

 Note
If you want to add all columns of a data source to the output, in the context menu of the data source, choose Add To
Output.

5. (Optional) Create constant output columns.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 55/74
1/10/2020
Create new output columns and assign it with constant values.

a. Choose the Mapping tab.

b. In the Output Columns section, choose + (Create Constant).

c. In the Create Target and Manage Mapping dialog box, provide a name for the new constant output column.

d. Provide the required data type, length, and scale values.

e. In the Source Column dropdown list, select the required column from the data source with which you want to map
the constant output column.

f. In the Constant Value text eld, provide the required constant value.

g. Select is Null checkbox, if you want to assign a null value to the constant output column.

 Note
If you do not provide any constant value, then the tool, by default, considers the constant output column value
as null.

h. Choose OK.

6. (Optional) De ne calculated columns.

a. Choose the Calculated Columns tab.

b. Choose + (Add).

c. Select and expand the new calculated column.

d. De ne the calculated column.

7. (Optional) De ne input parameters or variables.

a. Choose the Parameters tab.

b. Choose (Add).

c. Select Input Parameter or Variable menu option.

d. Select and expand the new input parameter or variable.

e. De ne the input parameter or variable.

8. Add result as inputs to other view nodes.

a. In the view editor, select the minus view node.

b. Choose .

c. Drag the cursor to the view the node for which you want to provide the input.

Related Information
Create Calculated Columns
Assign Variables
Create Input Parameters

Use Hierarchy Functions


Users can model calculation views with hierarchy function view nodes that allow them to use several SAP HANA hierarchy
functions in the view de nition. The hierarchy functions typically help work with hierarchical data.

Context

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 56/74
1/10/2020
The hierarchy function view nodes enable you to use the hierarchy generator functions to generate hierarchies and to use the
hierarchy navigation functions on the generated hierarchies to efficiently compute ancestors, descendants, or siblings of nodes.

The tool supports using the following functions in the hierarchy function view nodes.

Generator Functions Description

Hierarchy Function Generates a hierarchy based on recursive parent-child source data.

Hierarchy Leveled Generates a hierarchy based on source data that has a leveled format.

Hierarchy Span Tree Generates a hierarchy for a recursive parent-child source containing only the rst shortest
path between each start and result node.

Hierarchy Temporal Generates a time-dependent hierarchy for recursive parent-child source data whose edges are
additionally quali ed by validity intervals.

Navigation Functions Description

Hierarchy Ancestors This function helps navigate all ancestors of a set of start nodes in a hierarchy.

Hierarchy Descendants This function helps navigate all descendants of a set of start nodes in a hierarchy.

Hierarchy Siblings This function helps navigate all siblings of a set of start nodes, including the start
nodes.

Related Information

Generate Hierarchies
Use built-in hierarchy generator functions that SAP provides to translate the diverse relational source data into hierarchies that
can be represented in a generic and normalized tabular format.

Context
The structure of a hierarchy generated from a hierarchy function is always the same, regardless of the original format of the
source data, and consists of an ordered list of its nodes. The nodes themselves are represented by a minimal set of orthogonal
hierarchy topology attributes plus a projection of the original source attributes.

Procedure
1. Open the required calculation view in the view editor.

2. From the tool palette of the editor, drag a hierarchy function view node to the editor.

3. Add data sources.

a. Select the hierarchy function view node.

b. Choose (Add Data Source).

c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.

The hierarchy is generated from the data source that you select. You can add only one data source in the hierarchy
view node.

d. Choose Finish.

4. Select a hierarchy generator function and de ne values.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 57/74
1/10/2020
a. In the details pane, select the De nition tab.

b. Choose .

c. Select Generator.

d. Select the required hierarchy function that you want to use to generate the hierarchy.

5. (Optional) Concatenate multi-column tuple-like node identi ers into single scalar values.

You can combine two or more scalar expressions into a single value for use as a unique, reliable value by hierarchy
generator functions. The resulting values have additional characters encoding the lengths of the components to ensure
uniqueness within the results.

a. Select the Enable Multide nition checkbox.

b. Select the attribute columns that de ne parent-child relationships.

6. Provide values to generate the hierarchy.

Property Value Generator


Functions

Parent In the value help list, select an attribute column in the data source that speci es the Hierarchy
PARENT_ID (parent). Function,
Hierarchy Span
Tree, Hierarchy
Temporal

Child In the value help list, select an attribute column in the data source that speci es the Hierarchy
NODE_ID (node). Function,
Hierarchy Span
Tree, Hierarchy
Temporal

Level In the De ne Levels pane, choose + to select one more attribute columns that speci es Hierarchy Leveled
the levels.

Start The start condition helps identify the root nodes. Use the expression editor to specify the Hierarchy
start condition as an expression. Function,
Hierarchy Span
 Remember
Tree, Hierarchy
The start condition is applied as an additional lter on the data source. If a start
Temporal
condition is not speci ed, then root nodes are identi ed by the condition WHERE
PARENT_ID IS NULL.

Depth The depth can be a xed value or an input parameter. It speci es the maximum search Hierarchy
depth during hierarchy generation. Function,
Hierarchy Span
Tree, Hierarchy
Temporal

Valid From and In the value helps list, select the attribute columns that provides the required validity Hierarchy
Valid To intervals. You can provide a xed value from selected attribute columns or use an input Temporal
parameter to specify the validity intervals.

Orphan Handling In the dropdown list, select a value that speci es the orphan handling policies. Hierarchy
Function
Ignore: Orphans are silently ignored and is the default behavior.
 Note
Error: If the input data contains any orphans, then an error is raised.

Root Node: Top-level orphans are treated as root nodes.

Adopt: Top-level orphans are adopted as children of the last root behind its
regular descendants.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 58/74
1/10/2020

Property Value Generator


Functions

Cache Orphans are always ignored for Hierarchy Span Tree, Hierarchy Temporal, and Hierarchy Hierarchy
Leveled generatorIn the dropdown list, select a value that speci es the caching policy for Function,
the generated hierarchy.Orphans are always ignored for Hierarchy Span Tree, Hierarchy Hierarchy Span
Temporal, and Hierarchy Leveled generator functions. Tree, Hierarchy
Temporal,
Cache: The generated hierarchy is cached if the system assesses the source to
Hierarchy Leveled
be reliably deterministic. Cache is the default behavior.

Do not Cache: The generated hierarchy is not cached.

Force Cache: The generated hierarchy is cached even if the source cannot be
assessed to be reliably deterministic.

Cache helps improve the subsequent navigation of the same hierarchy.

Siblings Order By In the Siblings Order By pane, choose + to use one or more output columns of the view Hierarchy
node to SIBLING ORDER BY and sort the output sibling nodes. In the Sort Direction Function,
dropdown list, select the required sort direction. Hierarchy Span
Tree, Hierarchy
Temporal,
Hierarchy Leveled

7. De ne output columns.

If required, you can add one or more columns from the data source as output columns to the view node.

a. In the editor toolbar, choose (Expand Details Panel).

b. On the Mappings tab, select the columns you want to add to the output of the hierarchy function view node.

 Note
Some default attributes are calculated by the hierarchy generator function and are part of the output columns.
You cannot edit them.

c. In the context menu, choose Add To Output.

 Note
If you want to add all columns of a data source to the output, in the context menu of the data source, choose In
the value help list, select an attribute column in the data source that speci es the PARENT_ID (parent).In the
value help list, select an attribute column in the data source that speci es the PARENT_ID (parent).nullnullnull
nullAdd To Output.

8. (Optional) De ne input parameters or variables.

a. Choose the Parameters tab.

b. Choose (Add).

c. Select Input Parameter or Variable menu option.

d. Select and expand the new input parameter or variable.

e. De ne the input parameter or variable.

9. Add result as inputs to other view nodes.

After creating a hierarchy function view node to generate hierarchies, you can use hierarchy generator function results as
inputs to other view nodes. For example, you can use the generated hierarchy as inputs to other hierarchy functions view
nodes that are de ned with hierarchy navigation functions.

a. In the view editor, select the hierarchy function view node.

b. Choose .

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 59/74
1/10/2020
c. Drag the cursor to the view node for which you want to provide the input.

Related Information

Navigate Hierarchies
SAP HANA provides built-in navigation functions that use optimized algorithms on the hierarchy attributes to efficiently compute
ancestors, descendants, or siblings of nodes.

Context
Complex calculations on the hierarchy involving a start set of nodes and potentially multiple steps beyond their immediate
neighborhood are termed navigations.

Procedure
1. From the tool palette of the editor, drag a hierarchy function view node to the editor.

2. Add inputs to the view node.

a. Add a hierarchy for the navigator function to operate on.

To add, use the result of a hierarchy generator function as input to this view node.

 Remember
The hierarchy generator result must contain all the basic hierarchy attributes computed by a hierarchy generator
function.

b. (Optional) Add an additional input table or a data source with a lter condition that speci es the start nodes.

This means that, input to the hierarchy function view node must contain, at minimum, a column named or aliased
as START_RANK that has a data type that can be cast to BIGINT. If the start nodes are not speci ed, then the
navigation starts from all nodes in the hierarchy.

3. Specify the hierarchy generator.

If you are specifying the start node as an additional input table or a lter condition on a data source, then also specify
which of the two inputs in the view node is a hierarchy generator function.

a. In the details pane, select the Mapping tab.

b. In the Data Sources pane, select a data source that is a hierarchy generator.

c. In the Properties section, set the value of Type as Generator.

4. Select the required navigation function.

a. In the editor toolbar, choose (Expand Details Panel).

b. In the details pane, select the De nition tab.

c. Choose .

d. Select Navigation and choose a menu option.

Menu Option Description

Hierarchy Ancestors Lists all ancestors of a set of start nodes in a hierarchy.

Hierarchy Descendants Lists all descendants of a set of start nodes in a hierarchy

Hierarchy Siblings Lists all siblings of a set of start nodes, including the start
nodes.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 60/74
1/10/2020

 Remember
If the start nodes are not speci ed, then the navigation starts from all nodes in the hierarchy.

5. Provide values to navigate the hierarchy.

Navigation Property Value


Function

Distance From Specify a scalar integer value as minimum HIERARCHY_DISTANCE. You can provide a xed
Hierarchy Ancestor
value or use an input parameter to provide the value at runtime.

Distance To Specify a scalar integer value as maximum HIERARCHY_DISTANCE. You can provide a
xed value or use an input parameter to provide the value at runtime.

The Distance From and Distance To values for Hierarchy Ancestor function is always less
than or equal to 0.

Start Rank (Optional) In the value help list, select a START_RANK column that has a data type that can
be cast to BIGINT.

Distance From Specify a scalar integer value as minimum HIERARCHY_DISTANCE. You can provide a xed
Hierarchy
value or use an input parameter to provide the value at runtime.
Descendants
Distance To Specify a scalar integer value as maximum HIERARCHY_DISTANCE. You can provide a
xed value or use an input parameter to provide the value at runtime.

The Distance From and Distance To values for Hierarchy Descendants function is always
greater than or equal to 0.

Start Rank (Optional) In the value help list, select a START_RANK column that has a data type that can
be cast to BIGINT.

Hierarchy Siblings Start Rank (Optional) In the value help list, select a START_RANK column that has a data type that can
be cast to BIGINT.

6. De ne output columns.

a. On the Mappings tab, select the columns you want to add to the output of the hierarchy function view node.

 Note
Some default attributes are calculated by the hierarchy generator function. The navigation function projects all
default attributes calculated by the source hierarchy generator function plus a lateral projection of the
corresponding START record. You must retain all of them as the output columns of this view node and cannot
edit them.

b. In the context menu, choose Add To Output.

 Note
If you want to add all columns of a data source to the output, in the context menu of the data source, choose Add
To Output.

7. (Optional) De ne input parameters or variables.

a. Choose the Parameters tab.

b. Choose (Add).

c. Select Input Parameter or Variable menu option.

d. Select and expand the new input parameter or variable.

e. De ne the input parameter or variable.

8. Add result as inputs to other view nodes.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 61/74
1/10/2020
After creating a hierarchy function view node to navigate hierarchies, you can use hierarchy navigation function results as
inputs to other view nodes. For example, if you want to project only some of the output columns to calculation view output,
then you can use the result of this view node in a projection view node to project only the required columns as output
columns of the calculation view.

a. In the view editor, select the hierarchy function view node.

b. Choose .

c. Drag the cursor to the view node for which you want to provide the input.

Related Information

Anonymize Data Using Calculation Views


Use the anonymization capabilities in SAP HANA to anonymize calculation view output. Anonymization methods help gain
statistically valid insights from your data while protecting the privacy of individuals.

Context
SAP HANA supports the methods k-anonymity and differential privacy. To attain the anonymization capabilities, the graphical
calculation view editor provides an anonymization view node. You can use this view node to select the required anonymization
method and to de ne the level of privacy for a data set.

Procedure
1. Open the required calculation view in the view editor.

2. From the tool palette of the editor, drag and drop an anonymize view node to the editor.

3. Add data sources.

a. Select the anonymize view node.

b. Choose (Add Data Source).

c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.

 Note
You can add only one table or one view as a data source in an anonymization view node. You can also use other
view nodes (join, projection, aggregation, and so on) as inputs to the anonymize view node, provided you are
using only tables or views as data sources.

 Restriction
Do not use input parameters in any of the expressions below the anonymize view nodes.

d. Choose Finish.

4. De ne output columns.

a. In the editor toolbar, choose (Expand Details Panel).

b. On the Mapping pane, select the columns you want to add to the output of the anonymize view node.

c. In the context menu, choose Add To Output.

 Note
If you want to add all columns from the data source to the output, in the context menu of the data source,
choose Add To Output.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 62/74
1/10/2020
5. Select an anonymization method.

Select an anonymization method that you want to use to anonymize the calculation view output.

a. In the Details tab, choose .

b. Select the required anonymization method.

SAP HANA supports the methods k-anonymity and differential privacy.

Anonymization Method Description

k-anonymity k-anonymity is an intuitive and widely used method for modifying data for privacy
protection. k-anonymity anonymizes data by generalizing the individual record in a
group of similar records, thus signi cantly reducing the possibility that the individual
can be identi ed.

Differential Privacy Differential privacy anonymizes data by randomizing sensitive information but in a
way that regardless of whether an individual record is included in the data set or not,
the outcome of statistical queries remains approximately the same. Differential
privacy provides formal statistical privacy guarantees.

6. (Optional) De ne input parameters or variables.

a. Choose the Parameters tab.

b. Choose (Add).

c. Select Input Parameter or Variable menu option.

d. De ne the input parameter or variable.

7. Add result as inputs to other view nodes.

a. In the view editor, select the anonymization view node.

b. Choose .

c. Drag the cursor to the view node for which you want to provide the input.

Next Steps
For more information on Anonymization also see, SAP HANA Data Anonymization in the SAP HANA Security Guide for SAP HANA
Platform.

Related Information
Con gure k-Anonymity
Con gure Differential Privacy

Con gure k-Anonymity


In the anonymization view node de nition, con gure parameters and provide values based on the selected anonymization
method.

Procedure
1. In the Sequence Column dropdown list, select a value.

The tool populates the values in the dropdown list based on the output columns of the anonymization view node. The data
type of sequence columns ( seq column) are INT and BIGINT only.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 63/74
1/10/2020
2. In the k text eld, de ne the required k-value.

The k value is the minimum number of distinct values in the generalization hierarchy of a Quasi-identifying information
column.

3. In the Loss text eld, enter the required loss value.

The loss parameter helps specify the proportion of records that can be dropped from the results in order to limit the extent
of generalization.

4. In the Quasi Columns pane, choose + to de ne columns that contain the quasi identifying information.

5. For each column and for every distinct column value de ne the generalization hierarchies.

You can de ne new generalization hierarchies, or use an external calculation view to de ne the generalization hierarchies.

6. If you want to de ne a new generalization hierarchy, select a column and choose >.

a. For the selected column, if you want to import all distinct column values to the editor, choose Import Values.

b. If you want to add a new row, in the Details pane, choose (Add Row).

Adding new row helps add a new column value to the generalization hierarchy.

c. If you want to add a new hierarchy level to the column value, in the Details pane select the column value and choose
(Add Level).

For each distinct column value, you can add one or more levels and de ne an hierarchy structure level-by-level. You
can also copy and reuse the hierarchy de nition of a selected column value to another column value.

 Remember
Use only string values to de ne the levels. The value for the last level is always *.

7. If you want to copy the hierarchy de nition, in the Details pane select a column value and choose (Copy Hierarchy)

If you want to reuse this copied de nition to one or more column value, select the new column values and choose
(Paste Hierarchy).

8. Choose Back to go back and save the generalization hierarchy de nition.

9. If you want to use an external calculation view to de ne the generalization hierarchy, then in the Generalization
Hierarchies dropdown list, choose External.

a. In the Column Hierarchy value help, select the calculation view that provides the generalization hierarchy de nition.

10. In the Weight text eld, enter the required value.

By weighting one or more columns in your de nition of k-anonymity, you can adjust the relative importance of different
attributes. This allows you to to in uence the data quality after generalization in the quasi-identifying columns.

11. In the Min Level text eld, enter the required value.

You can restrict the possible generalization levels of quasi-identifying columns by setting a minimum value.

12. In the Max Level text eld, enter the required value.

You can restrict the possible generalization levels of quasi-identifying columns by setting a maximum value.

Related Information
Example: Sequence Column

Example: Sequence Column


Sequence column is a column that represents the sequence for the data set. It helps distinguish new and inserted data.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 64/74
1/10/2020
The sequence column is a user de ned eld containing (INT or BIGINT) integers of the input table. It follows these rules:

Rule 1: Each row in squence column is a unique value.

Rule 2: It is monotonic increasing. This means that, same values are not set twice even though they are note present
anymore.

Rule 3: Values are always greater than zero.

Rule 4: Each individual is only once in the table.

Example
Assume the following table

SeqCol Sickness

1 Cough

2 Cancer

If a new value is inserted, it gets a new unique sequence column value. (Following Rule 1)

SeqCol Sickness

1 Cough

2 Cancer

3 AIDS

Now assume we delete an entry

SeqCol Sickness

1 Cough

3 AIDS

and insert another entry. In this case, we choose "4" as the next sequence entry. (Following Rule 2)

SeqCol Sickness

1 Cough

3 Cancer

4 Broken Legs

 Note
The user is responsible for the maintenance of this column. In the calculation view editor, we only require a reference to this
column.

Con gure Differential Privacy


https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 65/74
1/10/2020
In the anonymization view node de nition, con gure parameters and provide values based on the selected anonymization
method.

Procedure
1. In the Sequence Column dropdown list, select a value.

The tool populates the values in the dropdown list based on the output columns of the anonymization view node. The data
type of sequence columns ( seq column) are INT and BIGINT only.

2. In the Epsilon text eld, enter the required values.

This is the value epsilon (ɛ). Typical values are 0.1 or 0.01. However, for some use cases, setting epsilon to a value larger
than 1, for example 5, is ne as well. eε is the maximum multiplicative impact on the probability of any outcome. The lower
the value of epsilon, the greater the privacy required and the more noise is applied.

3. In the Sensitivity text eld, enter the required values.

Sensitivity is typically range of values. Choosing the correct sensitivity is necessary to guarantee differential privacy.
Setting the sensitivity higher than necessary will reduce the quality of the anonymized data.

4. In the Noised Column dropdown list, select the required column value.

The data types of noised columns are FLOAT or DOUBLE only.

Model Table Functions as View Nodes


Use table function view nodes to model table functions with both tabular input parameters and scalar input parameters. These
view nodes help provide mappings to inputs of table function.

Context
Table functions are user-de ned functions that accepts multiple inputs, but returns exactly one result table. The inputs are scalar
inputs or table type inputs.

You can use a table function as a data source directly within a view node (for example, a projection view node, aggregation view
node, and more). But, with SAP HANA 2.0 SPS 01 onwards, you can also use the new table function view node to model table
functions with both, tabular input parameters and scalar input parameters.

In table function view nodes, you can add a table function type, and use other data sources or output of other view nodes to ll the
tabular input parameters of the table function. You can create input parameters or constants in the table function view node to ll
the scalar input parameters of the table function.

After modeling a table function, you can use the output of the table function as inputs to other view nodes in the calculation view.

Procedure
1. Open the required calculation view in the view editor.

2. From the tool palette of the editor, drag a table function view node to the editor.

3. Add a table function as a data source.

Have at least one table function type in the table function view node. The table function inputs the table type de nition
along with its columns and scalar parameters.

a. Select the table function view node.

b. Choose (Add Table Function).

c. In the Find Data Sources dialog box, enter the name of the table function and select it from the list.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 66/74
1/10/2020
d. Choose OK.

4. Add data sources.

Add tables (data sources) that provides inputs to the table function. You can also add a view node from the calculation view
as an input to the table function view node.

a. Select the table function view node.

b. Choose (Add Data Source).

c. In the Find Data Sources dialog box, enter the name of the data source and select it from the list.

d. Choose Finish.

5. De ne input columns.

Map the columns and parameters from the data source with columns and scalar parameters of the table function
respectively.

a. In the editor toolbar, choose (Expand Details Panel).

b. Choose the Input Mapping tab.

c. Select the required column from the data source that you want to add as input columns to the table function.

d. Drag the cursor to the Input Table Type columns.

 Note
Map columns with matching data types.

6. (Optional) Create constants

Create new input columns and assign it with constant values. You can map constants with scalar input parameters of the
table function.

a. Choose the Input Mapping tab.

b. Choose (Create Constant).

c. Enter a constant value.

d. Choose OK.

7. (Optional) De ne input parameters or variables.

You can create both input parameters and variables within the table function view node. But, you can map only input
parameters with scalar input parameters of the table function.

a. Choose the Parameters tab.

b. Choose (Add).

c. Select Input Parameter or Variable menu option.

d. Select and expand the new input parameter or variable.

e. De ne the input parameter or variable.

8. Add result as inputs to other view nodes.

You can see the output columns of the table function view node in the Columns tab.

a. In the view editor, select the table function view node.

b. Choose .

c. Drag the cursor to the view the node for which you want to provide the input.

Related Information
Create Input Parameters
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 67/74
1/10/2020
Assign Variables

Filter Output of View Nodes


Apply lters on columns of view nodes to lter their output.

Context
For example, you could apply lters to retrieve sales of a product where (revenue >= 100 AND region = India) OR (revenue >=50
AND region = Germany). You can also de ne lters using nested or complex expressions.

Filters on columns are equivalent to the HAVING clause of SQL. Filters help optimize the calculation view execution. At runtime,
the system executes the lters after performing all the operations de ned in the lower view nodes.

You can de ne lters on columns using a lter expression, and can use the column engine language or the SQL language to de ne
the lter expression.

Procedure
1. Open the required calculation view in the view editor.

2. Select a view node.

 Note
You cannot apply lter on output columns of the graph nodes, table function view nodes, non-equi join view nodes,
anonymize view nodes, or hierarchy function view nodes of a calculation view.

3. Filter output of a view node.

Apply lters on output columns of a view node to lter its output results.

a. In the editor toolbar, choose (Expand Details Panel).

b. Choose the Filter Expression tab.

c. In the Language dropdown list, select the required language.

d. In the expression editor, enter the expression that de nes the required lter conditions.

Use the elements, functions, and operators in the Filter Expression tab to build your expression.

For example,

(revenue >= 100 AND region = India) OR (revenue >=50 AND region = Germany)

 Tip
In the expression editor, the tool provides hints for all supported functions. The hints give you more information
on the functions, its purpose, and syntax.

4. (Optional) Ignore multiple outputs.

If you have modeled a calculation view in which you are using the same view node as an input to multiple other view nodes,
you can push down the lters de ned in the top node to the lower nodes at execution.

a. Select the view node that is used as inputs in multiple view nodes.

b. Choose the Mapping tab.

c. In the Properties section for the view node, select the Ignore Multiple Output for Filters checkbox.

 Note
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 68/74
1/10/2020
Ignore multiple output is described with this example.

If you have de ned a lter in ViewNode_1, the default behavior of the engine is to not push down the lters to the lower
nodes (ViewNode_3). This behavior is to avoid any impact to results of ViewNode_2. You can override this behavior by
setting the Ignore Multiple Output for Filters ag in ViewNode_3. Setting this ag pushes down the lter de ned in
ViewNode_1 to ViewNode_3.

5. (Optional) Handling lters for calculation views with rank nodes.

If you have modeled a calculation view with a rank node as an input to any of the top nodes, and if you have de ned a lter
on the top node, you can push down the lter to nodes below the rank node at execution.

a. Select the rank node.

b. Choose the Mapping tab.

c. In the Properties section of the rank node, choose Allow Filter Push Down.

Filter Using Fuzzy Search Parameters


The calculation view editor enables you to create and use fuzzy search parameters to lter attribute columns in the projection
view nodes.

Context
In the fuzzy search parameter de nition, you de ne the fuzzy search string and the required fuzzy score. Fuzzy search is a fast and
fault-tolerant search feature for SAP HANA. A fuzzy search returns records even if the search term contains additional or missing
characters or other types of spelling errors.

For example, you can create a fuzzy search parameter FP with con dence as 0.8 and default search string as Softwar, and
apply the search parameter on the attribute column, CATEGORY. At runtime, the SQL query includes a placeholder,
"$$FP$$"=>'Softwar', and as a result, it returns data for the category values as Software, Softwares, Softwar, and similar.

Procedure
1. Open the required calculation view in the view editor.

2. Double-click the view node in which you want to de ne the fuzzy search parameters.

3. In the Parameters tab, choose .

4. Choose the Fuzzy Search Parameter menu option.

5. Select and expand the new fuzzy search parameter.

6. De ne the fuzzy search parameter.

You can de ne more than one fuzzy search parameter for a calculation view.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 69/74
1/10/2020
a. In the Name text eld, provide a name for the parameter.

b. In the Default Search String textbox, enter the required search string.

c. In the Con dence text eld, enter the required fuzzy score.

You can either use a xed value between 0 to 1 as the fuzzy score, or use an input parameter to de ne the fuzzy
score value at runtime. In the value help, choose the required type with which you want to provide the fuzzy score
value.

7. Select attribute columns.

Select the attribute columns on which you want to perform the fuzzy search. The tool lters and projects the attribute
column values based on the search string and the fuzzy score de ned in the fuzzy search parameter.

 Note
You can perform fuzzy search only for attribute columns in the projection view nodes. In addition, you can perform fuzzy
search only on tables as data sources. This means that, the selected projection view node must have only tables as the
data source.

a. Double-click the required projection view node in which you want to assign the parameters.

b. In the details pane, choose the Fuzzy Search Filter tab.

c. Select the required fuzzy search parameter and the corresponding attribute column on which you want to perform
the fuzzy search.

You can use the value help to select one or more attribute columns. If you have selected more than one attribute
column, then the tool performs a logical OR of all attribute columns.

d. Choose + to assign another fuzzy parameter to the same or different attribute columns.

If you have assigned more than one fuzzy search parameter to the same attribute column, then the tool performs a
logical AND of all parameters.

Supported Data Categories for Calculation


Views
The tool supports three types of data categories to classify calculation views. The following table explains each of these data
category types.

Data Category Description

Cube Calculation views with data category Cube are visible to the reporting tools and support data analysis with
multidimensional reporting.

For graphical calculation views with data category as Cube, the tool provides aggregation as the default view node.
Also, an additional aggregation column behavior is available that you can use to specify the aggregation types for
measures.

Dimension Calculation views with a data category Dimension are not visible to the reporting tools and do not support data
analysis. However, you can use these calculation views as data sources in other calculation views for any
multidimensional reporting purposes.

If the data category is Dimension, you cannot create measures. You can only consume them with SQL. For example,
you can use such calculation views to ll simple-list user interfaces, where recurring attribute values are not a
problem, but are desired. The output node offers only attributes of numerical data types.

For graphical calculation views with data category Dimension, the tool provides projection as the default view node.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 70/74
1/10/2020

Data Category Description

SQL Access Only Calculation views with data category SQL Access Only are not visible to the reporting tools and do not support
multidimensional reporting.

However, you can use these calculation views as data sources in other calculation views for any multidimensional
reporting purposes.

For graphical calculation views with data category SQL Access Only, the tool provides projection as the default view
node.

If you change the data category of the view from CUBE or DIMENSION to SQL ACCESS ONLY and if the view is
directly accessed by a front end tool, then validate whether your front-end tool can still report on the respective view.

 Note
Do not change to data category "SQL ACCESS ONLY" if you have explicitly modeled hierarchies in the Semantics
node. For more information, see 2821857

Related Information
Create Graphical Calculation Views

Example: Using Keep Flag


Using keep ag for an attribute column helps in ensuring that calculations occur at a granularity, and that it includes the attributes
agged as "Keep".

The keep ag property for attribute columns in uence the result set of a calculation view.

When to Use the Keep Flag


You use the keep ag property when the level of granularity has an impact on the outcome of a measure. This means that, you use
keep ag for attribute columns whenever the order matters for executing the calculations and aggregations.

For example, consider the expression, a⊕b + c⊕d ≠ (a+c) ⊕ (b+d), where ⊕ is an operator:

In this expression: If ⊕ = +, then the keep ag property is not relevant because, a+b+c+d = (a+c)+(b+d).

But, in the expression, if ⊕ = *, then the keep ag property is relevant. a*b+c*d ≠ (a+c)*(b+d)=a*b+a*d+c*b+c*d.

Example
The following is an example where order of execution matters. Different results occur depending on whether the aggregations are
executed rst, or if the calculations are executed before the aggregations.

Day Value1 Value2

1 2 3

1 3 4

2 1 3

Scenario 1: Aggregate on the day level and then multiply.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 71/74
1/10/2020

Day Value1 Value2 Multiplied

1 5 7 35

2 1 3 3

Scenario 2: First multiply and then aggregate on the day level.

Day Value1 Value2 Multiplied

1 2 3 6

1 3 4 12

2 1 3 3

For scenario 2, the aggregation results is,

Day Value1 Value2 Multiplied

1 5 7 18

2 1 3 3

Preview Calculation View Output


After modeling calculation views based on your requirements, you can deploy them and preview its output from within the same
tool.

Context
The tool provides multiple preview options. You can preview output data of calculation views in simple tabular format, or you can
preview output data in graphical representations such as, bar graphs, area graphs, and pie charts. If your calculation view is
de ned with hierarchies, then the tool allows you to preview the output data in hierarchical representations.

You can also export and download the output data to .csv les. The tool also allows you to preview the SQL query that the tool
executed to fetch the output data.

Procedure
1. Start SAP Web IDE in a Web browser.

2. In the Workspace view, select the required calculation view to preview its output.

3. In the context menu, choose Data Preview.

4. Provide input parameter or variable value.

If you have de ned any input parameters in the calculation view, provide the required input parameter values.

a. Select the required operator.

b. Provide values for the From and To elds based on the selected operator.

c. In the toolbar, choose (Open Content).

In the Raw Data tab, the tool displays the output data in tabular format.

5. (Optional) Apply lters.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 72/74
1/10/2020

a. If you want to apply lters on columns and preview the ltered output data, in the toolbar, choose (Add Filter).

b. Choose Add Filters.

c. Select the required columns and de ne the lter conditions.

d. Choose Apply.

6. Export output data, if required.

If you want to export the raw data output to a .csv le,

a. In the toolbar, choose (Download).

b. In the Delimiter dropdown list, select the required delimiter that the tool must use to separate the values in the .csv
le.

c. Choose Download.

7. View SQL query for the calculation view, if required.

a. If you want to view the SQL query that the tool executed to fetch the data, in the toolbar, choose SQL.

b. In you want to view, edit and execute the SQL query in SQL editor, choose (Edit SQL Statement in SQL
Console).

8. Preview output of calculation views in graphical representations.

The tool supports bar graph, area graph, pie chart and table charts, and other graphical representations to preview the
output of a calculation view. These graphical representations allow more detailed analysis of output data.

a. In the menu bar, choose Analysis.

b. Con gure the axis values by dragging and dropping the required attributes and measures to the Label Axis and the
Value Axis.

The tool displays the output data in graphical representation. Select the required chart icons in the menu to view
the output in different graphical representation.

c. In the toolbar, choose (Display Settings) to toggle legends and values.

d. If you want to view the query SQL query that the tool executed to fetch the data for the provided axes
con gurations, in the toolbar, choose SQL.

e. If you want to export the charts as .png les to your local system, in the toolbar, choose (Download) and select
Chart.

f. If you want to export the raw output data as .csv les to your local system, in the toolbar, choose (Download)
and select Data.

9. Preview output of hierarchies.

The SAP Database explorer provides a Hierarchies tab to preview output of calculation views that contain hierarchies. If
you have de ned any hierarchies in calculation views of type Dimension or Cube, you can preview output in hierarchical
tree structures.

 Note
The tool does not support preview output of compound parent-child hierarchies in calculation views.

a. In the menu bar, choose the Hierarchies tab.

In the Available Objects pane, the tool displays all hierarchies de ned in the calculation view including hierarchies
from shared dimensions, if any. It also displays the measures de ned in the calculation view.

b. Drag and drop a hierarchy to the Selected Hierarchy pane.

 Restriction
The tool does not support preview of multiple hierarchies at the same time. You can preview output in
hierarchical tree structure of only one hierarchy at a time.

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 73/74
1/10/2020
c. (Optional) If you want to preview the output with one or more measures from the calculation view, drag and drop the
measure to the Selected Measure(s) pane.

The tool constructs the output data in hierarchical tree structure for the selected con guration. The root node is
expanded and the number of records displayed depends on the MDX console or SQL console settings.

 Note
MDX queries do not support history enabled parameters and does not obey any pruning settings de ned for the
calculation view. Thus, they are not part of the hierarchy data preview.

d. If you are previewing output of a calculation view with data category as CUBE and if you want to view the MDX query
that the tool executed to fetch the output data, in the toolbar, choose MDX.

e. If you are previewing output of a calculation view with data category as Dimension and if you want to view the SQL
query that the tool executed on the BIMC tables to fetch the output data, in the toolbar, choose SQL.

f. If you want to export the output data to a .csv le, in the toolbar, choose (Download).

10. Preview output of intermediate nodes.

If you have activated the calculation view, you can also preview the output of any of its intermediate view nodes. This
preview helps know the output data that is passed to the higher view node levels.

a. Switch to the Development perspective.

b. In the Workspace view, select the required calculation view and open it in the view editor.

c. Right-click the required intermediate view node and choose Data Preview.

Related Information
Create Graphical Calculation Views

https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=20467161&topics=92143ac2a1c5460688c5a7177b… 74/74

You might also like