Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
techvarun
Specialist II
Specialist II

Sum Of percentages and Percentage Calculation in Load Script

Hi experts,

 

This may be a silly question and but I am quite confused here. below the scenario.

 

I have the below load script

 

LOAD * ,Interest/Balance as Rate INLINE [
Key, Interest, Balance
1, 10, 5
2, 20, 25
3, 30
4, , 40
5, 50, 98
6, 60, 17
7, , 99
8, 100, 1000
9, 120, 12
10, 140, 8
];

 

and populating a table like below 

 

KeySum(Rate)Sum(Interest)Sum(Balance)
 34.44530.001304.00
12.0010.005.00
20.8020.0025.00
30.0030.000.00
40.000.0040.00
50.5150.0098.00
63.5360.0017.00
70.000.0099.00
80.10100.001000.00
910.00120.0012.00
1017.50140.008.00
    

 

But My expected table should look like below 

 

KeySum(Rate)Sum(Interest)Sum(Balance)Rates (expected)
 34.44530.001304.002.460377358
12.0010.005.002
20.8020.0025.000.8
30.0030.000.000
40.000.0040.000
50.5150.0098.000.510204082
63.5360.0017.003.529411765
70.000.0099.000
80.10100.001000.000.1
910.00120.0012.0010
1017.50140.008.0017.5

 

I know we can't sum rates but how do we acheive the correct rates at all levels.

 

Please advice. I must calculate the rates on the  load script.

 

 

2 Replies
joseph_morales
Creator II
Creator II

Hi @techvarun ,

 

I copied your script into a new qlikview file and i got the following result:

Captura1.PNG

The expression in rates column:

if(Dimensionality()=0,
sum(Balance)/sum(Interest),
sum(Rate)
)

Chart Properties -> number format -> Rates

Captura2.PNG

 

Regards

Best Regards,
Joseph Morales
bharathadde
Creator II
Creator II

Please find the attachment for solution

Hope this works for you Smiley Happy