Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Import expression with nested variable

Hi,

I am trying to import an expression through an external text file which has some variables in the expression. However it is not able to replace the variable value inside the expression. Details below:

Variable to be imported

SET vCurrentVolumeTRx= sum({<[Time_Vlookup.Month End Date]={">=(=$(vTrendStart))<=($(=vTrendEnd))"},[Time Bucket Type]={'Current'},[CAL_SRC]={'Sales'}>} if([Time_Vlookup.Month End Date]=[Month End Date],TRX_NORM));

Definition of variables used in the above expression

SET vTrendStart=min({<[Time_Vlookup.Time Bucket Name]=P([Time Bucket Name]), [Time_Vlookup.Time Bucket Type] = P([Time Bucket Type])>}[Time_Vlookup.Month End Date]) ;
SET vTrendEnd=max({<[Time_Vlookup.Time Bucket Name]=P([Time Bucket Name]), [Time_Vlookup.Time Bucket Type] = P([Time Bucket Type])>}[Time_Vlookup.Month End Date]) ;

I am getting the expression after import.

sum({<[Time_Vlookup.Month End Date]={">=<="},[Time Bucket Type]={'Current'},[CAL_SRC]={'Sales'}>} if([Time_Vlookup.Month End Date]=[Month End Date],TRX_NORM))

Appreciate your help.

Regards,

Sam

7 Replies
vishsaggi
Champion III
Champion III

can you try this?

SET  variablename = '=sum({<[Time_Vlookup.Month End Date]={"$(= '>=' & $(vTrendStart)) & '<=' $(vTrendEnd))"} ......';

Not applicable
Author

Thanks Vish for the reply, however using ' in the export statement does not work. The expression value stores all the statement in the load script which have been coded after its declaration.

vishsaggi
Champion III
Champion III

Visibility: @Sunny T

Is it possible to share a sample app ? I am not sure where else to look into, I am sure it is a small modification some where which can resolve. Let us see if Sunny can give some suggestions ?

Not applicable
Author

I'm actually experiencing much of the same issue.  While trying to import the following from an excel file:

Sum({$<MonthYearList = {'$(=Max(MonthYearList))'}, [Trending] = {'Revenue'}>} [Amount]); I lose the entire $(=Max(MonthYearList)) expression within the variable.  I have yet to find a solution to this issue. 

vishsaggi
Champion III
Champion III

Sunny can you help on this ? stalwar1

Peter_Cammaert
Partner - Champion III
Partner - Champion III

There are a lot of solutions to this $-sign-expands-too-early problem in QlikView Script.

But probably the simplest one is to replace the $-sign in your expression source with another character (one that won't be used for anythjing else, like a pound sign #) and use the Replace() function once the string has been loaded into a variable. Use the Replace() function during the very last step, to avoid getting substituted again.

If you load expressions as strings in your script, and they shouldn't expand yet, use a LET statement and the concatenation operator like in:

LET vMyExpression = 'Sum($' & '(vWhatMustBeReplacedLaterOn))';

Spmitting the $() construct will avoid the $-sign substitution from happening right there and then.

Best,

Peter

Anil_Babu_Samineni

Have you resolve the problem or else Try this without Variables

sum({<[Time_Vlookup.Month End Date]={'>=' &

"$(min({<[Time_Vlookup.Time Bucket Name]=P([Time Bucket Name]), [Time_Vlookup.Time Bucket Type] = P([Time Bucket Type])>} [Time_Vlookup.Month End Date]))" '<=' &

"$(max({<[Time_Vlookup.Time Bucket Name]=P([Time Bucket Name]), [Time_Vlookup.Time Bucket Type] = P([Time Bucket Type])>}[Time_Vlookup.Month End Date]))"}, [Time Bucket Type]={'Current'}, CAL_SRC={'Sales'}>} if([Time_Vlookup.Month End Date]=[Month End Date],TRX_NORM))


Note: Would you try using UAT for Min and Max Variable on your Text Object. Is there any chance to share Application using Scramble Data.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful