cancel
Showing results for 
Search instead for 
Did you mean: 

How to write the sum of same values into each line in a CalculationView?

Cr_1234
Explorer
0 Kudos

Hi friends,

I am trying to create calculated columns in a HANA Calculation View. The calculated columns should show the sum of IDs with same characteristics.  E.g. we have 7 IDs with the TYPE "W05" and 6 IDs with the TYPE "W10". The endresult should contain the table with all IDs, where we have in the calculated column the values "7" or "6" in each row with TYPE "W05" or Type "W10".

Here is an example of three calculated columns that I need to create (AMOUNT_SAME_TYPE, AMOUNT_SAME_TYPE_CHARNAM_CHARVAL, AMOUNT_SAME_CHARNAM_CHARVAL):

IDTYPECHARNAMCHARVALAMOUNT_SAME_TYPEAMOUNT_SAME_TYPE_CHARNAM_CHARVALAMOUNT_SAME_CHARNAM_CHARVAL
W05001W05GW_G02242736
W05002W05GW_G02242736
W05003W05GW_G02242736
W05004W05GW_G02354723
W05005W05GW_G02354723
W05006W05GW_D07100712
W05007W05GW_D07200712
W10001W10GW_G02242636
W10002W10GW_G02242636
W10003W10GW_G02242636
W10005W10GW_G02354613
W10006W10GW_D07100612
W10007W10GW_D07200612

I have no idea, how I can archieve this.. Is here an expert that could help me with my issue?

Accepted Solutions (0)

Answers (1)

Answers (1)

Cr_1234
Explorer
0 Kudos

I could solve the first keyfigure by a tablefunction with the select code:

COUNT(*) OVER(PARTITION BY TYPE) AS AMOUNT_SAME_TYPE

but unfortunately the PARTITION BY argument does not work for more than one field?!

nachtaktiv
Participant
0 Kudos
are you sure about "...PARTITION BY ... only one field..." ? pay attention to correct syntax