Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
venkatbza
Creator
Creator

How to Calculate cumulative value

Hi Friends,

 

I am trying to convert below excel logic's to Qlikview script level but I am not able to find the way please help me.

=SUMIF(A3:A8,B3)

My Data is below, I have  'value' and 'reference value' as columns now I need to create a Column called 'Cumulative Value'. Cumulative Value column condition is sum of Value if reference value is greater then or equal to(=SUMIF(A3:A8,B3)).

DATA:

ValueReference value
10>=11
20>=21
30>=35
40>=41
50>=55
60>=60

 

OUT required:

  OUTPUT Column 
ValueReference valueCumulative value 
10>=12200EX:-Output column should show the sum of "value" what ever the value is >=12  
20>=21180EX:-Output column should show the sum of "value" what ever the value is >=21  
30>=35150EX:-Output column should show the sum of "value" what ever the value is >=35  
40>=41110EX:-Output column should show the sum of "value" what ever the value is >=41  
50>=5560EX:-Output column should show the sum of "value" what ever the value is >=55  
60>=6060EX:-Output column should show the sum of "value" what ever the value is >=60 

 

Thanks,

Venkat

Labels (2)
4 Replies
sunny_talwar

Here is one option... but may be not the best out there...

Table:
LOAD Value,
	 [Reference value],
	 Num#(Replace([Reference value], '>=', '')) as [Reference value Tmp];
LOAD * INLINE [
    Value, Reference value
    10, >=11
    20, >=21
    30, >=35
    40, >=41
    50, >=55
    60, >=60
];

Join (Table)
LOAD Value as TestValue
Resident Table;

FinalTable:
LOAD Value,
	 [Reference value],
	 Sum(If(TestValue >= [Reference value Tmp], TestValue)) as Output
Resident Table
Group By Value, [Reference value];

DROP Table Table;

 

venkatbza
Creator
Creator
Author

Hi Sunny,

Thanks for your reply, it is working fine but Join condition is creating performance issue, it took hours to reload. Instead of join I have tried with concatenation but showing wrong values. is there any other way that I can use instead of JOIN condition?

Thanks

sunny_talwar

All ways would run into the same issue....

Brett_Bleess
Former Employee
Former Employee

Venkat, have a look at the following post, not sure if it will help or not, but I figured it might be worth a shot.

https://community.qlik.com/t5/Qlik-Design-Blog/Full-Accumulation-example/ba-p/1475445

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.