Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
SureshUK
Contributor II
Contributor II

Passing parameter while calling a variable

Hi,

I have a variable which accepts a number as a parameter and returns a number.

I have no problem including this in the chart by passing a value from another from another column.

$(vCalcFinalScore(Score))

but it doesn't work when I call the variable like this:

$(vCalcFinalScore(TextBetween(Score,'|','|',2)))

I am getting an error "TextBetween takes 3-4 parameters"

The column Score is an other expression on the same chart.

Not sure what I am missing here.

1 Solution

Accepted Solutions
tresesco
MVP
MVP

When the variable first encounters with a comma, it terminates as the end of the first argument and that is why you can't pass any value/expression that has comma in between in that way. Alternatively you could have one more variable to hold the expression and pass it in the variable as argument. PFA

View solution in original post

8 Replies
tresesco
MVP
MVP

How do you define the variable?

SureshUK
Contributor II
Contributor II
Author

The variable vCalcFinalScore has some validations to return a single digit number. A simplified definition looks like this:

if ($1>99 and $1<999, if (substringcount($1,'4')>substringcount($1,'3'),4,3),99)

tresesco
MVP
MVP

So, you are supposed to pass a number as argument to the variable. And do you expect 'TextBetween(Score,'|','|',2)' to return a number? I guess a sample qvw would be easier to investigate.

SureshUK
Contributor II
Contributor II
Author

The expression "Final Value-fails" doesn't return anything when I use textbetween function output and as parameter. The "Final Value-works" does return right value when an expression value is passed as parameter.

tresesco
MVP
MVP

When the variable first encounters with a comma, it terminates as the end of the first argument and that is why you can't pass any value/expression that has comma in between in that way. Alternatively you could have one more variable to hold the expression and pass it in the variable as argument. PFA

SureshUK
Contributor II
Contributor II
Author

Sorry that I can't open your QVW. I am using v12 personal edition.

Can you please paste both the expression and variables you have included?

tresesco
MVP
MVP

vText =TextBetween('|123|22|334|3|','|','|',1)

$(vCalcFinalScore(vText))

SureshUK
Contributor II
Contributor II
Author

This works! Thanks