If..then..elseif..else..end if
if..then 控制陳述式是一種陳述式選項建構,會根據一或數個邏輯條件強制指令碼執行遵照不同的路徑。
控制陳述式通常用於控制指令碼執行的流程。在圖表運算式中,請改用 if 條件式函數。
Syntax:
If condition then
[ statements ]
{ elseif condition then
[ statements ] }
[ else
[ statements ] ]
end if
由於 if..then 陳述式是控制陳述式,因而會以分號或行尾來結束,所以這四個可能的子句 (if..then、elseif..then、else 和 end if) 都不能超過行邊界。
Arguments:
引數 | 描述 |
---|---|
|
可評估為 |
|
是一或多個 Qlik Sense 指令碼陳述式的任何群組。 |
Example 1:
if a=1 then
LOAD * from abc.csv;
SQL SELECT e, f, g from tab1;
end if
Example 2:
if a=1 then; drop table xyz; end if;
Example 3:
if x>0 then
LOAD * from pos.csv;
elseif x<0 then
LOAD * from neg.csv;
else
LOAD * from zero.txt;
end if