Friday, 2 June 2017

How Classify The Classes based on Percentage in SAP HANA

Degree classification has a long history in our universities. It is widely accepted by students, parents and employers as the measure of academic achievement.

In this blog I am classifying the Student classes based on there percentage. If Student get above 60 percentage then they will get “FIRST CLASS” or If Student get between 60 to 50 percentage then they will get “SECOND CLASS” or If Student get below 50 percentage they will get “THIRD CLASS”.

For Implementing this scenario I took two calculated columns one for calculating Percentage other one for Specifying Class.

Below are the steps to implement “How Classify The Classes based on Percentage in SAP HANA”.

Step 1) Create one Table with the name “STUDENT_DETAILS” in our schema with following structure

SAP HANA Tutorials and Materials, SAP HANA Certifications, SAP HANA Guide

Insert Below Values into our Table

SAP HANA Tutorials and Materials, SAP HANA Certifications, SAP HANA Guide

Step 2: Create Calculation view in our package with the name “STUDENT_CLASS”

SAP HANA Tutorials and Materials, SAP HANA Certifications, SAP HANA Guide

Select STUDENT_DETAILS table in projection and Select the all columns.

SAP HANA Tutorials and Materials, SAP HANA Certifications, SAP HANA Guide

Create One calculated column for Calculating Percentage.

SAP HANA Tutorials and Materials, SAP HANA Certifications, SAP HANA Guide

Create another calculated column for calculated for class classification.

SAP HANA Tutorials and Materials, SAP HANA Certifications, SAP HANA Guide

Use the following logic to classifying the classes.

if(“MARKS_PERCENTAGE”>=60,‘FIRST CLASS’,if(“MARKS_PERCENTAGE”>=50 and “MARKS_PERCENTAGE”<60,‘SECOND CLASS’,if(“MARKS_PERCENTAGE”<50,‘THIRD CLASS’,‘FAIL’)))

Add projection to aggregation and select the calculated columns MARKS_PERCENTAGE and CLASS

SAP HANA Tutorials and Materials, SAP HANA Certifications, SAP HANA Guide

Save and Activate the View.

select the data preview.

Output:

SAP HANA Tutorials and Materials, SAP HANA Certifications, SAP HANA Guide

Above output we can see the CLASSES Classification in last column.