Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Qlik Community,
I'm working on an automation in Qlik Cloud and encountered a problem when converting a string to a list. Here’s the situation:
Problem Description:
I have a string that looks like this: Item1, Item2, Item3
I assign it to a variable using the following operation: { "Operation": "Set ItemsSTR equal to Item1, Item2, Item3" }
Then, I try to convert this string to a list: { "Operation": "Add <list> to ItemsList" }
However, the resulting list structure looks like this:
[ [ "Item1", "Item2", "Item3" ] ]
When I use a Loop block to iterate over this list, it only processes the first element (Item1).
Alternative Approach:
If I add each item individually, like this:
{ "Operation": "Add Item1 to ItemsList" }
{ "Operation": "Add Item2 to ItemsList" }
{ "Operation": "Add Item3 to ItemsList" }
The resulting list is correctly formatted as:
[ "Item1", "Item2", "Item3" ]
In this case, the Loop block iterates over each item correctly.
Output from Automation:
String "Item1, Item2, Item3" convert to List and run in LOOP
Item ListArray
Item String Item1, Item2, Item3
++++++++++++++++
Output in Loop>Item : Array
Add items "Item1, Item2, Item3" to List and run in LOOP
Item List Array
++++++++++
Output in Loop>Item : Item1
Output in Loop>Item : Item2
Output in Loop>Item : Item3
Question:
Why does the List operation convert the string differently when using "Add <list> to ItemsList"? How can I make the conversion work correctly without manually adding each item?
I would appreciate any advice or suggestions!
Thank you in advance!
Example automation in attach
Create a temporary variable of type String (e.g., ItemsTempList).
Perform the following operation to set its value:
This will convert your string into a list-like string.
Next, use a Loop block to iterate through ItemsTempList:
Create a temporary variable of type String (e.g., ItemsTempList).
Perform the following operation to set its value:
This will convert your string into a list-like string.
Next, use a Loop block to iterate through ItemsTempList: