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: 
eduardolcouto
Contributor
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
sunny_talwar

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

View solution in original post

6 Replies
YoussefBelloum
Champion
Champion

Hi,

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

eduardolcouto
Contributor
Contributor
Author

Sure...

Attached.

eduardolcouto
Contributor
Contributor
Author

Sure...

Attached.

sunny_talwar

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
Contributor
Contributor
Author

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

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