Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
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
rubenmarin

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
Creator
Creator

Hi Monica,

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

Greets, Halmar

rubenmarin

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))

MayilVahanan

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

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

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

MayilVahanan

Hi ,

Its coming from same table?

If so,

You can write like this'

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

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

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
Author

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

Not applicable
Author

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
Author

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).