Showing posts with label union of two projection. Show all posts
Showing posts with label union of two projection. Show all posts

Wednesday, June 17, 2020

UNION IN SAP HANA CALCULATION VIEW

Unions are used to combine the result set of two or more data sources.

Let us consider a scenario where we need combine two set of test details of the student. We have two tables , one with internal test details and another with final test. And we are going use union node to combine these two tables.(If you are having common records in two projection then we will get two records in union - Union in HANA act as UNION ALL function)


Below are the tables which we are going to combine.


Now drag Union node and add both projection in the union.

Click on the Auto Map By Name icon for mapping the source field names to target.


Similar to other nodes we can create calculated column, use input parameters and rename the field names.

After mapping the source fields, add all fields to the output and activate the view.


Now we can find the both data combined in the final data preview.


Note: If you are having same records with measure in two projection and we are using union node then we will get two records in union. The Measure value would be doubled. To avoid the doubling issue  what we can do is

1. Create calculated column CA_FLAG1 and CA_FLAG2 in each projection with 'X' in calculated column 

2. Add Aggregation node on top of the union and bring all fields

3. Then create another calculated for measure if CA_FLAG1='X' and CA_FLAG2 = 'X' then measure/2(handle if you are having 0 in measure)else same measure. This will solve our doubling issue in union node



Featured Post

Extending/Increasing Key figure Length with custom Domain

  In this Post, We will learn how to increase Key figure length with new domain or custom Domain.   Go to RSD1 Tcode and enter NOHDB Tcode...

Popular Posts