Quantcast
Channel: SCN : Document List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 1183

Modelling: Column to Row Transpose using Projection

$
0
0

Contributors:

Abani Pattanayak, HANA COE (abani.pattanayak@sap.com)

Martin Donadio, NGS Hana COE Argentina (martin.donadio@sap.com)


 

Background:

 

This is an alternative approach to Column to Row transpose discussed in Modelling: Column to Row Transpose using Matrix in HANA. In this article we'll use multiple projection steps in a calculation view to transpose from column to row.

 

Problem Statement:

 

The following is output of Analytic View (AN_DATA)

http://scn.sap.com/servlet/JiveServlet/downloadImage/102-50541-1-349197/DATA.PNG


We'd like to transform the dataset (from column to row) as shown below


http://scn.sap.com/servlet/JiveServlet/downloadImage/102-50541-1-349198/ROW_TO_COLUMN.PNG

 

Solution Option:

 

1. Build the calculation view as below. Insert one Project Node for each column (3 projections for "AGR", "OIL" and "TAX").

 

Calc View.PNG

 

2. Rename the Column "AMOUNT_OIL" to "AMOUNT" in Projection_OIL (highlighted in yellow in the above picture). Similarly rename 'AMOUNT_AGR" and "AMOUNT_TAX" in the other two projections

 

3. In the Union node, create a new target "AMT_TYPE" and map as below.

 

AMT_TYPE.PNG

4. Expose the DOCID, COUNTRY, AMT_TYPE and AMOUNT in the Aggregation node and activate the calculation view.

 

Result:

 

Now execute the following Query for the desired output

Output.PNG


Viewing all articles
Browse latest Browse all 1183

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>