# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Not applicable

## Cumulative Averages

How do I get a value for the cumulative value of any given ratio? I am computing Manufacturing Profit Margin % = Manufacturing Profit / Total Sales. I am trying to write an expression that will sum compute the overall value by taking Manufacturing Profit 1 + Manufacturing Profit 2 +Manufacturing Profit 3 / Total Sales 1 + Total Sales 2 + Total Sales 3 = Cumulative Manufacturing Profit Margin % for periods 1-3.  Any help?

1 Solution

Accepted Solutions
Not applicable

Hopefully this:

20 Replies
Not applicable

## Re: Cumulative Averages

Not sure I completely understand, do you have sample data or app that we can look at?

Best,

Sunny

Not applicable

## Re: Cumulative Averages

I simply want to cumulate the numerator and denominator before dividing to get the overall values of each.

Not applicable

## Re: Cumulative Averages

Try this:

RangeSum(Manufacturing Profit 1 + Manufacturing Profit 2 +Manufacturing Profit 3)/RangeSum(Total Sales 1 + Total Sales 2 + Total Sales 3)

Not applicable

## Re: Cumulative Averages

Or simply do this (but this might give you problems when you have nulls). RangeSum would be a better solution I believe.

(Manufacturing Profit 1 + Manufacturing Profit 2 +Manufacturing Profit 3)/(Total Sales 1 + Total Sales 2 + Total Sales 3)

Best,

Sunny

Not applicable

## Re: Cumulative Averages

No that didn't work, here is what I have thus far, and it is still not calculating. I am using full accumulation, and will need to calculate my cumulative margin similar to what's attached in Excel.

=Sum({\$<[Finance Data.Metric]={'Manufacturing Profit'}>} [Finance Data.Act/Fcst])
/
Sum({\$<[Finance Data.Metric]={'Total Sales'}>} [Finance Data.Act/Fcst])

Not applicable

## Re: Cumulative Averages

The file you attached is already accumulating Metric 1 and Metric 2? I wouldn't be able to help you if you don't give me a sample from raw data. I am not sure what exactly are you doing for accumulation. I hope that make sense.

Best,

Sunny

Not applicable

## Re: Cumulative Averages

Here is a better example:

 Month 1 2 3 Total Metric 2 23996 47980 33692 105668 Metric 1 6245 12489 22108 40842 Margin 0.260252 0.260296 0.65618 0.386512 This is what I want
Not applicable

Any idea?

Not applicable

## Re: Cumulative Averages

Give me sometime... checking it in a bit.

Best,

Sunny

Community Browser