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

Loop inside IFcondition

Hi

please confirm if we can make loops under If condition

If(Condition, Loop1 ,Loop2).

It would be good if you can explain with an example.

3 Replies
prieper
Master II
Master II

in the script: yes

IF Condition THEN

Loop1

ELSE

Loop2

END IF

Peter

Anil_Babu_Samineni

Why not, Something like below

If(Region = 'Andhra Pradesh', If(Sales > 30, 'Lowest Price', 'Highest Price'))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Actually, no. In QlikView script, there are two IFs: there is an IF() function that can be used in expressions, and there is an IF control statement that can be used in blocks of code. They look alike and may give you the impression that they do similar things. But they're to be used in different contexts.

An IF() function cannot contain loops (except if you consider the two-parameter SubField() function a "loop") because loops (like DO UNTIL/WHILE or FOR) are also control statements. And an IF (... THEN ... ELSE ... END IF) control statement can't be used inside expressions. That's how it is.

[Edit] The one in your OP is the function-version of course.