Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

loop

Hi All,

I have a field that contains numbers, lets say from 1 to 10(and not necessary that it contains only 10 entries, it can have hundreds of distinct entries) and a variable having numeric value(not static).

Now i want to use a loop such that if variable's value matches with any of the value in the field, it performs first expression (say display TRUE) else second expression(say displays FALSE)

let me know the loop condition and syntax.

Thanks

1 Solution

Accepted Solutions
sushil353
Master II
Master II

Hi,

In case you have that field containing numbers as Dimension of chart then you can simply use match function for desire expression to calculate..

in expression you can write: if(Match(field,$(Variable))>0,exp1,exp2)

HTH
sushil

View solution in original post

4 Replies
sushil353
Master II
Master II

Hi,

In case you have that field containing numbers as Dimension of chart then you can simply use match function for desire expression to calculate..

in expression you can write: if(Match(field,$(Variable))>0,exp1,exp2)

HTH
sushil

sujeetsingh
Master III
Master III

Where you want this loop in some script.

Let vTab=3;

Table:

LOAD * INLINE [

    ID, Values

    1, 25

    2, 23

    3, 34

    4, 21

    5, 12

];

Data:

load

ID, Values

,if(ID=$(vTab),'True','False') as Flag

Resident Table;

DROP Table Table;

tresesco
MVP
MVP

Try like:

     Load

               If(FieldValue=$(vVriable), 'True', 'False') as Flag

Anonymous
Not applicable
Author

Hi Deepak

if you are really looking for the loop option below is the code if not use the above one which is suggested by @sujeetsingh

Test:

LOAD * INLINE [

    Field

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

];

set variable=9;

for i = 1 to NoOfRows('Test')

  let find=FieldValue('Field',$(i));

  if($(i)=1)then

  Test1:

  NoConcatenate

  load Distinct $(find) as Field,if($(find)=$(variable),'True','False') as [True/False] Resident Test;

  else

  Concatenate(Test1)

  Load Distinct $(find) as Field,if($(find)=$(variable),'True','False') as [True/False] Resident Test;

  end if

next

drop table Test;

Regards

Harsha