Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
brunolovatti
Contributor II
Contributor II

Parametrized Variable Problem

Hi!

I've created some varibles that works like functions.

Example:

variable fVerbaSup

(

sum(

{

$<[Comprador]={$1},[Modalidade]={'SUPERMERCADO'}>

}

[Valor Verba]

)

)

Where $1 is the parameter.

I use it with success like:

$(fVerbaSup( "888 |*"))

But I could not pass more then one Comprador in the same parameter, like:

$(fVerbaSup( "888 |*", "304 |*" ))

It does not work and returns the sum of Valor Verba from Comprador 888 only.


Strange is the fact that if I do not create a variable and use the sum directly in the object, it works, like:


(

sum(

{

$<[Comprador]={"888 |*", "304 |*" },[Modalidade]={'SUPERMERCADO'}>

}

[Valor Verba]

)

)

Anybody has a suggestion on how I could pass more then one Comprador in the SAME PARAMETER?

I tried a lot of combinations without success.

$(fVerbaSup( "888 |*", "304 |*" ))


It must be in the same parameter because I have many others functions that will receive 1, 2, 3 or N Comprador.


Thank you!

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You cannot use a comma as part of the parameter value.  Even though it is in quotes, the comma will be treated as a parameter separator and 304 will be assigned to $2.

The only workaround I've found is to use a proxy character for the comma and do a replace in the expression.  Something like:

$<[Comprador]={$(=replace('$1','@',',')},[Modalidade]={'SUPERMERCADO'}>


and

$(fVerbaSup( "888 |*"@ "304 |*" ))


-Rob

View solution in original post

4 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You cannot use a comma as part of the parameter value.  Even though it is in quotes, the comma will be treated as a parameter separator and 304 will be assigned to $2.

The only workaround I've found is to use a proxy character for the comma and do a replace in the expression.  Something like:

$<[Comprador]={$(=replace('$1','@',',')},[Modalidade]={'SUPERMERCADO'}>


and

$(fVerbaSup( "888 |*"@ "304 |*" ))


-Rob

brunolovatti
Contributor II
Contributor II
Author

Did not work.

I'm doing more tests.

It worked now. Your code was missing another ) character.

(

sum(

{

$<[Comprador]={ $(=replace('$1', '@', ',')) },[Modalidade]={'SUPERMERCADO'}>

}

[Valor Verba]

)

)

Thank you very much!!

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

"It worked now. Your code was missing another ) character."


That's why I said "Something like" 


Glad you got it working!


-Rob

marcus_sommer

If it's just multiple (selections) values you could use a different syntax to avoid the comma-issue. Try it with:

$(fVerbaSup(("888 |*"|"304 |*")))

- Marcus