適用対象: ✅Microsoft Fabric✅Azure データ エクスプローラー✅Azure Monitor✅Microsoft Sentinel
動的配列の要素ごとの iif
関数。
array_iff()
関数とarray_iif()
関数は同等です
構文
array_iff(
condition_array、 when_true、 when_false)
構文規則について詳しく知る。
パラメーター
件名 | タイプ | 必須 | 説明 |
---|---|---|---|
condition_array | dynamic |
✔️ | booleanまたは数値の配列。 |
when_true | dynamic または scalar | ✔️ | 値またはプリミティブ値の配列。 condition_arrayが true の場合の結果です。 |
when_false | dynamic または scalar | ✔️ | 値またはプリミティブ値の配列。 condition_arrayが false の場合の結果です。 |
注
- 戻り値の長さは、入力 condition_arrayと同じです。
- 数値条件値は、0 でない場合は
true
と見なされます。 - 数値以外の条件値とブール値以外の条件値は、戻り値の対応するインデックス内で null になります。
- when_trueまたはwhen_falseがcondition_arrayよりも短い場合、欠損値は null として扱われます。
返品
条件配列の対応する値に従って、 when_true または when_false 配列値から取得された値の動的配列を返します。
例
次の例は、 array_iff()
関数を使用して配列内の要素を評価する方法を示しています。
print condition=dynamic([true,false,true]), if_true=dynamic([1,2,3]), if_false=dynamic([4,5,6])
| extend res= array_iff(condition, if_true, if_false)
出力
条件 | if_true | if_false | 解像 度 |
---|---|---|---|
[true、false、true] | [1, 2, 3] | [4, 5, 6] | [1, 5, 3] |
次の例は、数値条件値をブール値として扱う方法を示しています。
print condition=dynamic([1,0,50]), if_true="yes", if_false="no"
| extend res= array_iff(condition, if_true, if_false)
出力
条件 | if_true | if_false | 解像 度 |
---|---|---|---|
[1, 0, 50] | はい | いいえ | [はい、いいえ、はい] |
次の例は、数値以外の条件値と非ブール条件値で array_iff()
関数を使用する方法を示しています。
print condition=dynamic(["some string value", datetime("01-01-2022"), null]), if_true=1, if_false=0
| extend res= array_iff(condition, if_true, if_false)
出力
条件 | if_true | if_false | 解像 度 |
---|---|---|---|
[true、false、true] | 1 | 0 | [null, null, null] |
次の例は、配列の長さの不一致を関数が処理する方法を示しています。
print condition=dynamic([true,true,true]), if_true=dynamic([1,2]), if_false=dynamic([3,4])
| extend res= array_iff(condition, if_true, if_false)
出力
条件 | if_true | if_false | 解像 度 |
---|---|---|---|
[true,true, true] | [1, 2] | [3, 4] | [1, 2, null] |