Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Calculate the sum of an expression

Hello,

I have a question concerning a sum.

I have two columns :

The first column is the state (input/output)

The second is a value.

I want to make the sum of these values : when the value is an input I add the value to the sum and when the value is an output, I remove this value to the sum.

I know that it is an expression in my graph, but I don't know how to do that......

Thanks for your help

Annie

1 Solution

Accepted Solutions
jsn
Not applicable

Re: Calculate the sum of an expression

Hi Annie,

I would suggest creating a flag in your script for the state that is either 1 or -1:

If(State='input',1,-1) as StateFlag

Then you can use this in your calculation:

Value * StateFlag

3 Replies
jsn
Not applicable

Re: Calculate the sum of an expression

Hi Annie,

I would suggest creating a flag in your script for the state that is either 1 or -1:

If(State='input',1,-1) as StateFlag

Then you can use this in your calculation:

Value * StateFlag

Not applicable

Re: Calculate the sum of an expression

Hi Annie,

let's assume you have a chart with an expression to sum up a field called Val. And there is another Field called State with two values as described above. Then try to filter the sum similar to this:

Sum( If(State = 'Input', Val, 0) )

or, may be you like below :

Sum( If State = 'Input', Val, Val*-1))

HtH

Roland

Not applicable

Re: Calculate the sum of an expression

Thank youn Jphannes, you made my day =)