Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
eduardolcouto
New Contributor

Problem when I send parameters to variable function with a set analysys with two conditions.

Hi everyone,

When I send a parameter to function variable, and this parameter is a set analysis with two conditions, the function not work.

Example:
I create the bellow function:

vSomaMil = $1+1000

If I execute the function with the example bellow, the function work.
$(vSomaMil(Sum(Expression1)))
$(vSomaMil(Sum({<Alpha={'B'}>}Expression1)))

But, if I send like this:

$(vSomaMil(Sum({<Alpha={'B'},Dim1={'A'}>}Expression1)))

The function don't return anything.

Would anyone know why this problem occurs?

2019-04-18_07h47_13.png

 

1 Solution

Accepted Solutions

Re: Problem when I send parameters to variable function with a set analysys with two conditions.

The problem is the comma in your parameter

$(vSomaMil(Sum({<Alpha={'B'},Dim1={'A'}>}Expression1)))

When a variable is used with parameter, it assumes that each parameter is supplied separated by comma. In your case you don't want the expression to think that these are two separate parameter.

I have seen few solutions where the input parameter is supplied with a different character and then replaced with a comma using a Replace() function

Replace($(vSomaMil(Sum({<Alpha={'B'}#Dim1={'A'}>}Expression1))), '#', Chr(44))

I am not sure if this is the right syntax or not, but something on the similar lines is what you need

6 Replies
YoussefBelloum
Esteemed Contributor

Re: Problem when I send parameters to variable function with a set analysys with two conditions.

Hi,

would you be able to attach some sample data or qvf here ?

eduardolcouto
New Contributor

Re: Problem when I send parameters to variable function with a set analysys with two conditions.

Sure...

Attached.

eduardolcouto
New Contributor

Re: Problem when I send parameters to variable function with a set analysys with two conditions.

Sure...

Attached.

Re: Problem when I send parameters to variable function with a set analysys with two conditions.

The problem is the comma in your parameter

$(vSomaMil(Sum({<Alpha={'B'},Dim1={'A'}>}Expression1)))

When a variable is used with parameter, it assumes that each parameter is supplied separated by comma. In your case you don't want the expression to think that these are two separate parameter.

I have seen few solutions where the input parameter is supplied with a different character and then replaced with a comma using a Replace() function

Replace($(vSomaMil(Sum({<Alpha={'B'}#Dim1={'A'}>}Expression1))), '#', Chr(44))

I am not sure if this is the right syntax or not, but something on the similar lines is what you need

eduardolcouto
New Contributor

Re: Problem when I send parameters to variable function with a set analysys with two conditions.

Hi Sunny,
Your theory is correct, only the Replace I had to put in variable, like this:
$(=Replace($1,'#',','))
and the measure I had put like as:
$(vSomaMil('Sum({<Alpha={"B"}#Dim1={"A"}>}Expression1)'))

Thank you so much.

Re: Problem when I send parameters to variable function with a set analysys with two conditions.

Super awesome, glad you were able to figure it out on your own.