Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
In Java it is easy to drop this code inside a for loop and then get a nicely concatenated string.
a = new StringBuilder()
.append(a)
.append(b)
.toString();
However I haven't been able to do the same in Qlik Sene. I am trying to achieve something like this:
Let vMyVar = 'some text ';
For i = 1 to 3
vMyVar += i + Peek('City', $(i), 'weatherdata');
Next
Trace $(vMyvar );
Where $(vMyvar) must be in the end => some text 1 France 2 Madrid 3 Lund
I hope this is clear
Many thanks
Hi Jonas,
This works give one small correction in the code:
let vMyVar = '';
For i = 1 to 3
vMyVar = '$(vMyVar)' & ' ' & Peek('City', $(i), 'weatherdata');
Next
Trace $(vMyVar);
Note the single quotation around $(vMyVar).
I will still test it later with real data from the net and see what happens. I wished the Qlik syntax was more flexible like Java, JS or even action script, not sure into which category to put it
Thank you very much for your answer it was helpful and confirm something similar I found yesterday night.
I can think of two ways to achieve this right of the bat.
1. Use a variable in the loop:
let vMyVar = '';
For i = 1 to 3
vMyVar = $(vMyVar) & ' ' & Peek('City', $(i), 'weatherdata');
Next
Trace $(vMyVar);
2. Use Concat() to get all text rows of one table into the same row. Perhaps you need to merge your city and number field first and then concat:
Hi Jonas,
This works give one small correction in the code:
let vMyVar = '';
For i = 1 to 3
vMyVar = '$(vMyVar)' & ' ' & Peek('City', $(i), 'weatherdata');
Next
Trace $(vMyVar);
Note the single quotation around $(vMyVar).
I will still test it later with real data from the net and see what happens. I wished the Qlik syntax was more flexible like Java, JS or even action script, not sure into which category to put it
Thank you very much for your answer it was helpful and confirm something similar I found yesterday night.