Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Jagsfan82
Partner - Contributor III
Partner - Contributor III

Expansion with SubField creating error in If Statement

My If statement feels like it should be pretty simple, but my second SubField expansion is breaking the expression, and I'm assuming this is because I'm using $(=) instead of $(), but I'm not sure how else to pull in the expansion. 

If(GetSelectedCount(%vsExprR.Favorites)>0,$(=SubField(Concat(%vsExprR.Expansion,'|'),'|',1)),  
//Any Selections for Right Axis
If(GetSelectedCount(%vsExprL.Favorites)>1,$(=SubField(Concat(%vsExprL.Expansion,'|'),'|',2)),
//More than Two Selections for Left
$(mPolicyCount)))
//Anything Else​

 

Essentially this code is for the expression portion of a list box.  There are right and left list boxes.  The list boxes changes based on user selections.  They select a field they want to analyze and then they can choose a "Left" expression(s) and/or a "Right" expression(s).  The ExprL table has expression names in one field and dollar sign expansions in another.  These expansions correlate with expressions I already have stored as variables.  So when the user selects "Sum of Premium" this would link to $(vSumPremium), which is what I would want to use as the expression.

This works fine except when only one value is selected for the ExprL.Favorites, this means only one value for ExprL.Expansion is available, so evaluating for SubField number 2 creates an error in my expression.  It shows up as "-" in the list box, and when thrown into a text box returns "Error: Error in expression: ')' expected".  

I solved this by choosing the '2' in the second SubField to '-1', but would there be a way to get this to work while still pulling the second SubField?  Picture Below

 

Broken List Box.PNG

 

Labels (1)
1 Reply
SergeyMak
Partner Ambassador
Partner Ambassador

Hi!

I'd suggest you to share an example app. 

Another thing is to try to evaluate the expressions in text boxes separately: eg

SubField(Concat(%vsExprR.Expansion,'|'),'|',1)

for one 

and 

SubField(Concat(%vsExprL.Expansion,'|'),'|',2)

for another.

It might help you to understand what exactly is happening, when you make your selections

Regards,
Sergey