Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

Variables with sum and filters

I have such variable (in Variable Overview): vCost = SUM([Cost1])+SUM([Cost2]).

I want do sth like this (in Chart Properties -> Expressions -> Definition): SUM( {<[Some dimension]={'Option1'}>} vCost) - but I see that it is not correct. So my question is how to get filtered variable?

Thanks in advance!

Monika

1 Solution

Accepted Solutions

Re: Variables with sum and filters

Hi Monika, you can change to vCost variable to:

Alt(Cost1,0)+Alt(Cost2,0)

And then you can use those expressions:

SUM({<[Some dimension]={'Option1'}>} $(vCost))

View solution in original post

13 Replies
qlikhalmar
Contributor

Re: Variables with sum and filters

Hi Monica,

You have to add [Cost1] + [Cost2] in the variable, so without the SUM().

Greets, Halmar

Re: Variables with sum and filters

Hi Monika, you can change to vCost variable to:

Alt(Cost1,0)+Alt(Cost2,0)

And then you can use those expressions:

SUM({<[Some dimension]={'Option1'}>} $(vCost))

View solution in original post

Re: Variables with sum and filters

Hi

Try like this

In variable

SUM( {<[Some dimension]={'Option1'}>} [Cost1])+SUM( {<[Some dimension]={'Option1'}>} [Cost2])

And use vCost as expression.


Or

Directly use as

SUM( {<[Some dimension]={'Option1'}>} [Cost1])+SUM( {<[Some dimension]={'Option1'}>} [Cost2]) in expression

Not applicable

Re: Variables with sum and filters

Thanks for answer but it's too much writing as for me.

Re: Variables with sum and filters

Hi ,

Its coming from same table?

If so,

You can write like this'

SUM( {<[Some dimension]={'Option1'}>} [Cost1] + [Cost2])

Not applicable

Re: Variables with sum and filters

Hi Monica ,

dont declare variable with '=' i mean just write (SUM([Cost1])+SUM([Cost2])) like this in variable Overview(That means it will consider it as text)

& in Expression Change to vCost to $(vCost) u will get the correct ans

Not applicable

Re: Variables with sum and filters

Yes, I know. I used '=' just to show how variable vCost looks like.

Not applicable

Re: Variables with sum and filters

Nice to know, that if costs are from one table I can write like this. But the point is that I want to use sum of costs in many places, so I don't want to write their sum all the time.

Not applicable

Re: Variables with sum and filters

Thanks for reply. Your answer is the best as for me - you've also showed me that I can use Alt function to avoid errors (I think that this is for that ;p).