Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
curiousfellow
Specialist
Specialist

String in Inline load using expression with variable

In my load script I have a variable containing a numeric value.

I want to use this variable in an Inline load.

The formula I use is : This is my text $(variable)-1

So when the value of $(variable) = 2020 the result should be : This is my text 2019 

I tried a lot of various syntaxis but all of them fail (for example $(=$(variable) -1)

Is is possible to achieve my goal , if possible ....how ?

Labels (1)
7 Replies
edwin
Master II
Master II

what is your desired outcome?  what values do you want loaded in the table.  the inline load is intended to load into a table a list of values.  if you are using a variable, then there will only be 1 value.  so did you need only one line?  if so use instead autogenerate(1)

if you need multiple lines, you may need to explain the desired outcome.

edwin
Master II
Master II

assuming that some part of your code you stored 2020 into your variable:

load

'This is my text ' & ($(variable)-1) as fieldName

autogenerate(1);

edwin
Master II
Master II

even if you want to use this as part of your inline, you can do it a few ways, but if you want to separate the text from the calculation make sure your calculation is bracketed.  if you use 'this is my text' & $(variable) - 1, this part is done first: 'this is my text' & $(variable) 
then adding 1 to that will fail

jbhappysocks
Creator II
Creator II

Hello @edwin 

Can you really do this in an inline? To my knowledge you can expand variables in an inline, but you can't perform any calculations, everything is treated as fixed values. But I learn new things every day so please give an example how you would do this if it is possible 🙂 

For example, If this:  'this is my text' & $(variable)  is loaded in an inline Qlik will treat it as a fixed value and the output will be 'this is my text' & 2020, not this is my text 2020. 

 

@curiousfellow  As suggested by Edwin using autogenrate might be a better solution than an inline. But if you need to use an inline, creating a second variable before your inline is probably the easiest solution. Create a variable2 from your variable that contains the full string This is my text 2019 and load this in your inline instead.

 

 

edwin
Master II
Master II

i agree that the data in the inline is static.  however, you can add any expression in the load part :

load 'this is a test ' & '$(vVariable)' as note, A, B, C inline [
A, B, C
......
];

as you can see you can perform expressions on your loaded fields as well:

A + B as NewField,

jbhappysocks
Creator II
Creator II

Yes, lot's of way to do it outside of the actual inline, but not in it, that what I was hoping for here. If it is one thing I've learn with Qlik is always expect someone to have a solution for what you believe can't be done 🙂 

curiousfellow
Specialist
Specialist
Author

Thank you all for your response. My goal was to reduce the number of variables. In this case I have to deal with extra variables.