Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
kristof_j
Creator III
Creator III

variable with comma parameter

Hi all

I wanted to use a variable with parameter and use 'total' as parameter. Like this expression

$(eCountDistinct( total ))

So far so good.

When I want to expand the total with 2 parameter like 'total <product_level1, product_level2>' the comma is interpreted as the end of the variable parameter.

The following examples don't work:

  • $(eCountDistinct( total <product_level1, product_level2> ))
  • $(eCountDistinct( 'total <product_level1, product_level2>' ))
  • $(eCountDistinct( "total <product_level1, product_level2>" ))

How can I solve this?

22 Replies
santiago_respane
Specialist
Specialist

Hi,

for this i don't use variables with parameters. I use concatenation and substitution of variables like this:

eCountDistinct = Count(DISTINCT $(=MyParameterVar) customer)

MyParameterVar = TOTAL <product_level1,product_level2,product_level3>

MyExpression = $(eCountDistinct)

This way it always works and i never have to fight with commas in parameters.

Hope this helps.

Kind regards,

wcilliers
Partner Ambassador
Partner Ambassador

Hi All,

I have a similar problem and was hoping you might help. I am trying to use a variable to pass the parameter back. But by using a GetFieldSelections() in the variable to send back my selections as a parameter.

Please see attached.

Hope you can help.

Thanks in advance,

Wynand. !

sunny_talwar

May be see if attached is what you are looking for.

Best,

Sunny

wcilliers
Partner Ambassador
Partner Ambassador

Perfect, thanks Sunny!

kristof_j
Creator III
Creator III
Author

That works if you know how many parameters you want.

I don't know in advance how many I need or how many other colleagues will use.

That's why I wanted to use a comma in one value.

sunny_talwar

Hahahaha may be add upto $500 in advance

kristof_j
Creator III
Creator III
Author

Indeed but what do you if you have something like this

sum( $1 $2 $3 $4 customer)

and you want

sum( total<dim1, dim2> { <dim1 = {1}, dim2 = {2}> } customer)

That is my aim 🙂

Maybe I should write all the expressions in full

marcus_sommer

In general that's possible - you could replace everything with the parameters but you must be careful how to declare the various parameters and how they are then processed within the variables. If you want to replace nearly everything with multiplen dimensions within totals and set analysis and something more then you will need some efforts to build a stable logic and to find the right syntax for each type.

I think this will be helpful for you: (and read the comments, too)

Variables

Re: nested variable troubles

Comma problem (,) workaround for dollar sign expansion with parameters

- Marcus

Digvijay_Singh

$0 means how many parameters passed to the function. Not sure if that can be used in any sense.

On a lighter note 

Everything Should Be Made as Simple as Possible, But Not Simpler - Albert Einstein


Thanks,