Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
vidyas16
Partner - Contributor III
Partner - Contributor III

Defining Variable in Data Load Editor

Dear All,

I am trying to define a variable with sum involving aggr function in the data load editor. But the aggregation inside the aggr is evaluated. I just want store the expression with out being evaluated as the expression is related the selections made in the front end dashboard.

Ex: I want to store this expr = 'sum(aggr(1, $(=concat('[' & %Dimension & ']', ',' ))))' in a variable in data load editor, but the concat function is evaluated while reloading the dashboard itself and concat function returns null.

Request to provide some suggestions to resolve this issue.

Thanks,

Vidya

Labels (1)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The issue is the $(.  You have to break them up and & concat them back together:

Let myvar = 'sum(aggr(1, $' & '(=concat(''['' & %Dimension & '']'', '','' ))))'; 

As you can see in my example, you will need to specify two single quotes in the inner quotes to escape those. 

Another approach is to use a proxy char like @ and fix with replace:

Let myvar = replace('sum(aggr(1, @(=concat(''['' & %Dimension & '']'', '','' ))))', '@', '$'); 

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

4 Replies
tm_burgers
Creator III
Creator III

are you definined the variable using LET or SET; you want to use SET to store that expression as a string.

 

SET assigns the value to the variable without evaluation, as a string, the LET first evaluates the expression at the right part of the "=" sign, then stores the value.

 

vidyas16
Partner - Contributor III
Partner - Contributor III
Author

Thank you for the reply.

I am using SET only, this particular expression  $(=concat('[' & %Dimension & ']', ',' )) inside the aggr function is getting evaluated due to = and $ expansion.

I tried to define variable for this ($(=concat('[' & %Dimension & ']', ',' ))) as well  and use it in the main variable, but still it gets evaluated.

 

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The issue is the $(.  You have to break them up and & concat them back together:

Let myvar = 'sum(aggr(1, $' & '(=concat(''['' & %Dimension & '']'', '','' ))))'; 

As you can see in my example, you will need to specify two single quotes in the inner quotes to escape those. 

Another approach is to use a proxy char like @ and fix with replace:

Let myvar = replace('sum(aggr(1, @(=concat(''['' & %Dimension & '']'', '','' ))))', '@', '$'); 

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

vidyas16
Partner - Contributor III
Partner - Contributor III
Author

Thank you Rob. The Replace approach worked in my case.

Vidya