Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculate a variable's parameter as set-analysis

Hi

I have a variable that I sometimes want to use set analysis on (but not always).

I want to be able to use it as it is - i.e:

=$(sum_num)

--> would calculate sum(num)

or, alternatively use a parameter to pass a set analysis expression

=$(sum_num({<country={'US'}>}))

--> would calculate sum({<country={'US'}>} num)

_______________

What I've tried so far:

sum($1 num)

gives errors when I don't pass any variable (works great for =$(sum_num({<country={'US'}>})) though)

I've also tried

sum(if(NOT isNull($1),$1) num)

and

sum(alt($1,'') num)

But neither of those are working.

Any ideas?

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

I found a work around. SET SumNum = sum({<$1>} num)  works with =$(SumNum(Country={'US'})). It gives a bit of an ugly result (sum({<$1>} num)) if you don't give any parameter, but it works.

View solution in original post

7 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Your variable value should be

='Sum($1 num)'

then try this in text object or chart expression

=$(sum_num({<country={'US'}>}))

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Try  this (not tested) - Sum(If(Len('$1')=0,{$}, $1) num)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thanks, but it only works for

=$(sum_num({<country={'US'}>}))

not for

=$(sum_num5)

Not applicable
Author

Doesn't work unfortunately. Good idea regarding {$} though - I'll experiment a bit with that

jonathandienst
Partner - Champion III
Partner - Champion III

Did you try

=$(sum_num5())

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

to use with setanalysis

=$(sum_num({<country={'US'}>}))


without set analysis use

=$(sum_num({$}))


May this approach might helps

Not applicable
Author

I found a work around. SET SumNum = sum({<$1>} num)  works with =$(SumNum(Country={'US'})). It gives a bit of an ugly result (sum({<$1>} num)) if you don't give any parameter, but it works.