SAP HANA Analytic View: How to Create & Use

โšก Smart Summary

SAP HANA Analytic View models data as a star schema, joining a central fact table to attribute views so that transaction data can be aggregated on the fly for multidimensional analysis inside SAP HANA Studio.

  • ๐Ÿ”˜ Structure: A fact table holding transaction data sits at the centre, surrounded by dimension tables and reusable attribute views.
  • โ˜‘๏ธ Nodes: Data Foundation holds the fact tables, Star Join attaches the attribute views, and Semantics defines the output.
  • โœ… Measures: Several tables may sit in the data foundation, yet measures can be selected from only one of them.
  • ๐Ÿงช Example: PURCHASE_ORDER and PURCHASE_DETAIL join on PO_NUMBER, and the AT_PRODUCT attribute view joins on PRODUCT_ID.
  • ๐Ÿ› ๏ธ Activation: Validation and activation publish the view as a column view in the _SYS_BIC schema for reporting.
  • ๐Ÿ“ˆ Direction: Analytic views are deprecated, so new cube-style models belong in graphical calculation views.

Analytic view star schema modeling in SAP HANA

What is an Analytic View in SAP HANA?

An analytic view in SAP HANA is based on star schema modeling and represents an OLAP, or multidimensional, modeling object. It forms a cube-like structure that is used to analyze data, and it suits any scenario where aggregated data from the underlying tables is needed.

In an analytic view, dimension tables are joined to the fact table that holds the transaction data. A dimension table carries descriptive data such as product, product name, vendor or customer. A fact table carries descriptive data together with measurable data such as amount and tax.

Because the aggregation happens in memory at query time, no aggregate tables have to be stored. The view is defined once in SAP HANA modeling and reused by every report that reads it.

Example of SAP HANA Analytic View

Here, an analytic view is created for a purchase order, based on the attribute view “AT_PRODUCT” created earlier. The Purchase Order Header table and the Purchase Order Detail table supply the transaction data.

Run both scripts below in the SQL console of SAP HANA Studio before the modeling steps begin.

SQL script to create table “PURCHASE_ORDER” in “DHK_SCHEMA”

CREATE COLUMN TABLE "DHK_SCHEMA"."PURCHASE_ORDER"					
(		
PO_NUMBER NVARCHAR(10) primary key,							
COMPANY NVARCHAR (4),			
PO_CATEGORY NVARCHAR(2),			
PRODUCT_ID NVARCHAR(10),			
VENDOR NVARCHAR(10),			
TERMS NVARCHAR(4),			
PUR_ORG NVARCHAR(4),			
PUR_GRP NVARCHAR(3),			
CURRENCY NVARCHAR(5),			
QUOTATION_NO NVARCHAR(10),			
PO_STATUS VARCHAR(1),			
CREATED_BY NVARCHAR(20),			
CREATED_AT DATE		
);		

INSERT	INTO "DHK_SCHEMA"."PURCHASE_ORDER" VALUES(1000001,1000,'MM','A0001','V000001','CASH' ,1000,'GR1','INR',1000011,'A','HANAUSER','2016-01-07');																													
INSERT INTO "DHK_SCHEMA"."PURCHASE_ORDER" VALUES(1000002,2000,'MM','A0002','V000001','CASH',1000,'GR1','INR',1000012,'A','HANAUSER','2016-01-06');																			
INSERT INTO "DHK_SCHEMA"."PURCHASE_ORDER" VALUES(1000003,2000,'MM','A0003','V000001','CASH',1000,'GR1','INR',1000013,'A','HANAUSER','2016-01-07');																			
INSERT INTO "DHK_SCHEMA"."PURCHASE_ORDER" VALUES(1000004,2000,'MM','A0004','V000001','CASH',1000,'GR1','INR',1000014,'A','HANAUSER','2016-01-07');

SQL script to create table “PURCHASE_DETAIL” in “DHK_SCHEMA”

CREATE	 COLUMN TABLE "DHK_SCHEMA"."PURCHASE_DETAIL"					
(		
PO_NUMBER NVARCHAR(10) primary key,							
COMPANY NVARCHAR(4),			
PO_CATEGORY NVARCHAR(2),			
PRODUCT_ID NVARCHAR(10),			
PLANT NVARCHAR(4),			
STORAGE_LOC NVARCHAR(4),			
VENDOR NVARCHAR(10),			
TERMS NVARCHAR(4),			
PUR_ORG NVARCHAR(4),			
PUR_GRP NVARCHAR(3),			
CURRENCY NVARCHAR(5),			
QUANTITY SMALLINT,			
QUANTITY_UNIT VARCHAR(4),			
ORDER_PRICE DECIMAL(8,2),			
NET_AMOUNT DECIMAL(8,2),			
GROSS_AMOUNT DECIMAL(8,2),			
TAX_AMOUNT DECIMAL(8,2)			
);		


INSERT	INTO "DHK_SCHEMA"."PURCHASE_DETAIL"	VALUES(1000001,1000,'MM','A0001',1001,101,
'V000001','CASH',1000,'GR1','INR',10,'UNIT',50000.00,40000.00,50000.00,10000.00);																									
INSERT	INTO "DHK_SCHEMA"."PURCHASE_DETAIL"	VALUES(1000002,2000,'MM','A0002',1002,102,
'V000002','CASH',1000,'GR1','INR',10,'UNIT',60000.00,48000.00,60000.00,12000.00);																									
INSERT	INTO "DHK_SCHEMA"."PURCHASE_DETAIL"	VALUES(1000003,2000,'MM','A0003',1003,103,
'V000001','CASH',1000,'GR1','INR',20,'UNIT',40000.00,32000.00,40000.00,8000.00);																									
INSERT	INTO "DHK_SCHEMA"."PURCHASE_DETAIL"	VALUES(1000004,2000,'MM','A0004',1004,104,
'V000002','CASH',1000,'GR1','INR',20,'UNIT',20000.00,16000.00,20000.00,4000.00);																	

The two scripts create the tables “PURCHASE_ORDER” and “PURCHASE_DETAIL” together with their data.

How to Create an Analytic View in SAP HANA

An analytic view named “AN_PURCHASE_ORDERS” is created below from the attribute view “AT_PRODUCT” and the tables “PURCHASE_ORDER” and “PURCHASE_DETAIL”. The ten steps follow the order of the editor screens.

Step 1) Create a new analytic view from the package tree shown below.

  1. Select the Modelling sub-package under the DHK_SCHEMA package.
  2. Right-click and choose New.
  3. Select the Analytic View option.

New Analytic View option on the Modelling sub-package in SAP HANA Studio

Step 2) The information view editor opens for the analytic view. Complete the creation dialog shown below.

  1. Enter the analytic view name “AN_PURCHASE_ORDERS” and a label for it.
  2. Select the view type “Analytic View”.

Analytic view creation dialog with the name AN_PURCHASE_ORDERS and view type

Once the entries are complete, click the Finish button. The information view editor is then displayed for the analytic view.

Step 3) Add the tables from the schema to the Data Foundation node under the scenario pane. The scenario pane holds three nodes.

  1. Semantics: this node represents the output structure of the view.
  2. Star Join: this node creates the join that attaches the attribute views to the fact table.
  3. Data Foundation: this node holds the fact tables of the analytic view. Several tables can be added, but measures can be selected from only one of them.

Drag and drop the tables “PURCHASE_ORDER” and “PURCHASE_DETAIL” from DHK_SCHEMA onto the Data Foundation node, as shown below.

PURCHASE_ORDER and PURCHASE_DETAIL tables dropped on the Data Foundation node

Step 4) Add the attribute view to the Star Join node.

  1. Select the “AT_PRODUCT” attribute view from the Modelling package.
  2. Drag and drop the attribute view onto the Star Join node, as shown below.

AT_PRODUCT attribute view dragged onto the Star Join node of the scenario pane

Step 5) In the same window, work in the detail panel as directed.

  1. Click the Data Foundation node. The tables added to it appear in the detail section.
  2. Join the table “PURCHASE_ORDER” to the table “PURCHASE_DETAIL” on the “PO_NUMBER” field.
  3. Enter the join type and the cardinality.

Edit join screen joining PURCHASE_ORDER to PURCHASE_DETAIL on PO_NUMBER

Click the OK button to keep the join.

Step 6) Select the following columns in the same window.

  1. Select PO_NUMBER, COMPANY, PO_CATEGORY, PRODUCT_ID, PLANT and STORAGE_LOC from the “PURCHASE_DETAIL” table.
  2. Select the CURRENCY column from the “PURCHASE_DETAIL” table.
  3. Select GROSS_AMOUNT and TAX_AMOUNT.
  4. Select the PO_STATUS, CREATED_BY and CREATED_AT columns from the “PURCHASE_ORDER” table, which is the purchase order header.

Output columns of the data foundation highlighted in orange after selection

Every selected column, marked in orange, appears in the output of the analytic view.

Step 7) Join the attribute view to the fact table in the data foundation. Click the Star Join node in the scenario pane, as shown below.

Star Join node selected in the scenario pane of the analytic view editor

The attribute view and the fact table are displayed in the detail pane. Join the attribute view to the data foundation on the “PRODUCT_ID” column, as shown below.

Attribute view joined to the data foundation on the PRODUCT_ID column

Click the join link. A pop-up for Edit Join is displayed, where the join type is defined as “Referential” and the cardinality as 1…1.

Edit Join pop-up with join type Referential and cardinality 1 to 1

Click the OK button to confirm the star join.

Step 8) Define the attributes, the measures and the key of the view. Select the Semantics node in the scenario pane, as shown below.

Semantics node selected in the scenario pane to define attributes and measures

  1. Select the Columns tab in the detail pane.
  2. Define the column type as attribute or measure. Every column here is an attribute except “GROSS_AMOUNT”, which is defined as a measure.

Columns tab marking GROSS_AMOUNT as a measure and the rest as attributes

Step 9) Validate and activate the analytic view from the toolbar.

  1. Validate the analytic view.
  2. Activate the analytic view.

Validate and Activate icons on the analytic view editor toolbar

The analytic view “AN_PURCHASE_ORDERS” is now created and activated in the Analytic folder of the Modelling sub-package, as shown below.

AN_PURCHASE_ORDERS listed under the Analytic folder of the Modelling package

Step 10) Preview the data in the analytic view.

  1. Go to the toolbar section and click the “Data Preview” icon.
  2. Select Open in Data Preview Editor.

Data Preview icon opening the Data Preview Editor for the analytic view

Three tabs are available in the data preview editor. The Analysis tab takes attributes and measures by drag and drop into the label axis and the value axis, and shows the output as a chart, table, grid or HTML, as below.

Analysis tab charting purchase order measures against label axis attributes

The Distinct values tab shows the distinct values of one selected attribute at a time, as below.

Distinct Values tab listing the distinct entries of one selected attribute

The Raw Data tab shows the records in table format, as below.

Raw Data tab showing the analytic view records in table format

Note: an analytic view accepts only attribute views as its dimensions and does not support the union operator. Row-level restrictions on the activated view are applied through analytic privileges.

Attribute views and analytic views are deprecated as of SAP HANA 2.0 and are not available in SAP HANA Cloud, so new cube-style models are built as graphical calculation views of data category Cube with star join. The steps above still apply to existing SAP HANA 2.0 systems, and the modeling concepts carry over. More background is available in the SAP HANA series.

FAQs

An analytic view models one star schema with a single fact table supplying measures. A calculation view stacks projections, joins, unions and aggregations over any source, including other views, so it handles logic an analytic view cannot express.

The data foundation represents one fact table. Additional tables may be joined to enrich it with attributes, yet allowing measures from several of them would multiply rows during aggregation and return inflated totals.

Yes. Calculated columns, restricted measures, input parameters and variables are defined in the Semantics node. They are evaluated at runtime, so the underlying tables stay unchanged and every consumer of the view sees the same logic.

AI assistants in SAP tooling suggest join paths, flag unused columns and predict expensive aggregations from past query plans. Machine learning on workload traces also recommends which measures to expose, though a modeler still validates every result.

GitHub Copilot drafts the CREATE COLUMN TABLE and SELECT statements that feed or query a view, and it speeds up test data scripts. Generated SQL must still be reviewed against real HANA syntax, privileges and column names.

Analytic views remain usable in SAP HANA 2.0 but are deprecated. SAP HANA Cloud supports calculation views only, so existing analytic views are rebuilt as graphical calculation views of data category Cube with a star join node.

Row-level filtering is granted through analytic privileges, which restrict the values a user may read for chosen attributes. The view itself stays unchanged, and object privileges alone never limit which rows are returned.

Activation generates a column view in the _SYS_BIC schema. Any SQL client, SAP Analytics Cloud, SAP BusinessObjects or an ODBC or JDBC report can query that column view once the user holds the required privileges.

Summarize this post with: