Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Loop in expression or text box

I am trying to create a generate a loop in the expression/text box on the based of selection in a table.

On the basis of selection I got the string in the table which is separated by comma (,) and I want to run the loop to find out how many strings I have after using

=SubStringCount(Priority_Combination, ',' )

and I want to store this in a variable so that I can run a loop.

and further want to store each value of string in a variable.

thanks

13 Replies
Kushal_Chawda

Please explain with example

petter
Partner - Champion III
Partner - Champion III

ValueLoop()  function can help you with looping. Furthermore you could do a Concat() to join values from a field into a string or a string with multiple lines using a carriage return as a value separator - Chr(10).  

Maybe SubField() also can be of help to split a string into multiple values into conjuction with ValueLoop().

If you give a more specific use case / example it would be easier to suggest the right approach.

qlikviewwizard
Master II
Master II

Hi sumit.arora

Can you give an example with the sample data. So that it will help the folks to give quick and efficient solution.

Not applicable
Author

Hi All,

See attached image below:

As you see highlighted column Priority_Combination it has a string separated with comma (,) now I want to get each value of this string into variables, so I can identify which rules parameter are there in that particular rule.

New_Cat_Rule is the list box for the list of rules names and all have different combination.

Many thanks

Sumit

temp.jpg

sunny_talwar

May be this can be helpful.

Script:

Table:

LOAD * Inline [

RuleID | Priority_Combination

29 | VENDOR_NUMBER, PURCHASING_ORDER, MATERIAL_GROUP

] (delimiter is |);

Create a Variable vVar: SubField(Priority_Combination, ',', '$1')

Capture.PNG

And then in the text box object, try this as your expression:

=$(vVar(1)) to get VENDOR_NUMBER

=$(vVar(2)) to get PURCHASING_ORDER

=$(vVar(3)) to get MATERIAL_GROUP

Capture.PNG

Attaching the qvw for your reference.

HTH

Best,

Sunny

Not applicable
Author

Sunny,

Thanks for the quick response, but the Priority_Combination is not constant.

There are 40 set of rules on the basis of 9 parameters (Vendor, Contract, GL, text, category etc) and they changes on the basis of selection from the list box (New_Cat_Rule).

Sumit

sunny_talwar

Not entirely sure what you mean? Can you show an example???

Not applicable
Author

Issue is that data is too big behind so attach the file.

See below image now you can see 4 set of rows for the Priority_Combination and 4 different rules in the New_Cat_Rule list box.

Thanks

temp.jpg

sunny_talwar

In the above example what would be saved in a variable??? If we know that, we might be able to figure it out what can be done