# If..then..elseif..else..end if

if..then 制御ステートメントは、1 つ以上の論理条件に応じて異なるパスに従うようスクリプトを強制実行させるスクリプト選択構文です。

通常、制御ステートメントはスクリプト実行の流れを制御するために使用されます。チャートの数式では、代わりに if 条件関数を使用します。詳しくは「[if スクリプトおよびチャート関数](https://help.qlik.com/ja-JP/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ConditionalFunctions/if.htm)」を参照してください。

構文:

If condition then

[ statements ]

{ elseif condition then

[ statements ] }

[ else

[ statements ] ]

end if

if..then ステートメントは制御文であり、セミコロンまたは改行コードで終わっているため、使用可能な 4 つの節 (if..then、elseif..then、else、end if) が行をまたぐことはできません。

引数：

引数

| 引数 | 説明 |
| --- | --- |
| condition | True または False で評価できる論理式です。 |
| statements | 1 つ以上の Qlik Sense スクリプト ステートメントのグループ。 |

例1：

`if a=1 then`

> `LOAD * from 
>  abc.csv;` `SQL SELECT 
>  e, f, g from tab1;`

`end if`

例2：

`if a=1 then; drop table xyz; end if;`

例3：

`if x>0 
 then`

> `LOAD * from 
>  pos.csv;`

`elseif 
 x<0 then`

> `LOAD * from 
>  neg.csv;`

`else`

> `LOAD * from 
>  zero.txt;`

`end 
 if`

## 詳細を見る

* [End](https://help.qlik.com/ja-JP/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/End.htm)