Symptom
Select count (*) statement on top of a HANA graphical Calculation View leads to unexpected number of records in the result set.
Other Terms
HANA Calculation Engine
Reason and Prerequisites
It works as designed. The HANA Calculation Engine does not behave relational. At runtime the Calculation Engine executes an instantiation process, which transforms a stored calculation model to an executed calculation model based on a query on top of a calculation view.
The stored calculation model consists of a hierarchical order of calculation nodes. Each calculation node provides a defined set of attributes to the parent calculation node(s). Depending on the parent node(s) and the projection list in the query only the requested attributes will be considered in the calculation nodes of the executed calculation model.
The select count(*) statement does not specifiy a projection list of keyfigure(s) that shall be counted. Due the instantiation process the result set of the executed calculation model can vary.
Solution
You can overcome this situation by using built-in 'row.count' attribute in Analytical Views and its mapping into the graphical Calculation View
The built-in 'row.count' attribute is only generated, if an Analytical View contains one of the following characteristics:
- Input parameter
- Currency conversion
- Calculated attribute
- Calculated measure using attributes
In case the Analytical View does not have one of these characteristics, you can add e.g. a calculated attribute with a constant value.
Do the following steps in the HANA Modeler:
1. Create and activate the Analytical View as described
2. Create a graphical Calculation View on top of the Analytical View
3. You will see an additional 'row.count' attribute, when you click on the node for the Analytical View
4. Define the 'row.count' attribute as measure in the graphical Calculation View
5. It appears as 'row_count' measure, which is automatically mapped to the 'row.count' attribute of the underlying Analytical View
6. Activate the graphical Calculation View
7. Execute: 'Select sum("row_count") from "_SYS_BIC"."<CalcViewname>"'
The select statement returns the expected count(*) result for the underlying Analytical View.
Header Data
Released On | 04.04.2013 11:02:20 |
Release Status | Released for Customer |
Component | HAN-DB SAP HANA Database |
Priority | Recommendations / Additional Info |
Category | FAQ |
Validity
This document is not restricted to a software component or software component version
References
This document refers to:
SAP Notes
1764658 | HANA Calculation Engine Instantiation Process |
This document is referenced by:
SAP Notes (1)
1764658 | HANA Calculation Engine Instantiation Process |