Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

dollar sign expansion inside if statement not working

Hi,

When I use the below expression in a chart, it gives an error that allocated memory exceeded

if(GetSelectedCount(%SubDimension) > 0,

SUM(TOTAL <$(=%SubDimension)> Spend),

SUM(Spend)

)

However, the below expression works

if(GetSelectedCount(%SubDimension) > 0,

SUM(TOTAL Spend),

SUM(Spend)

)

This one alone also works

SUM(TOTAL <$(=%SubDimension)> Spend)

The only problem becomes when I use the dollar sign expansion inside the total and if it is inside an if statement

TOTAL <$(=%SubDimension)>

Any idea how to fix this?

15 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

If the variable contains the name of a single dimension field, omit the equal sign inside the $-expansion.

Not applicable
Author

It is not a variable. It is a field that contains the names of the dimensions. It has the names of six dimensions but the user can select which dimension should the chart show

Dollar equal sign then converts the selected value from the list to the dimension

The expression alone works exactly the way we want. However, inside the if statement, it stops to work if we have this kind of expression

vinieme12
Champion III
Champion III

Hi Syed,

Is this expression being used in a PIVOT table? with your dimension which holds Supplier, Product values moved to headers?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

Add two expressions with conditional enabled to overcome the memory issue


Expression1:

Conditional = if(GetSelectedCount(%SubDimension) > 0, 1 , 0)

Expression =  SUM(TOTAL <$(=%SubDimension)> Spend)

Expression2:

Conditional = if(GetSelectedCount(%SubDimension) > 0, 0 , 1)

Expression =  SUM(Spend)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
settu_periasamy
Master III
Master III

Hi syed,

I just created the sample. I think, it is working fine for me. Can you provide your sample which is not working for you..

Update:

it is not going to else part, if there is no selection because of null. that will create the expression like

Capture.JPG

The above one is error expression. that's why getting null result.

Based on Peter's suggestion, you can add the variable and use it in your expression.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

What happens if you replace $(=%SubDimension) with $(vSelectedDimension) and in Settings->Variable Overview you defined vSelectedDimension as

=%SubDimension

Might be easier to trace substitutions.

Best,

Peter