array_iif()array_iif()

动态数组上元素对应的 iif 函数。Element-wise iif function on dynamic arrays.

另一个别名:array_iff()。Another alias: array_iff().

语法Syntax

array_iif(ConditionArray, IfTrue, IfFalse]) array_iif(ConditionArray , IfTrue , IfFalse ])

参数Arguments

  • conditionArray:布尔值或数值组成的输入数组,必须是动态数组。conditionArray : Input array of boolean or numeric values, must be dynamic array.
  • ifTrue:值或基元值(ConditionArray 的相应值为 true 时的结果值)组成的输入数组 。ifTrue : Input array of values or primitive value - the result value(s) when the corresponding value of ConditionArray is true .
  • ifFalse:值或基元值(ConditionArray 的相应值为 false 时的结果值)组成的输入数组 。ifFalse : Input array of values or primitive value - the result value(s) when the corresponding value of ConditionArray is false .

说明Notes

  • 结果长度是 conditionArray 的长度。The result length is the length of conditionArray .
  • 数字条件值被视为 condition != 0 。Numeric condition value is treated as condition != 0 .
  • 非数字/NULL 条件值在结果的相应索引中将为 NULL。Non-numeric/null condition value will have null in the corresponding index of the result.
  • 缺失值(长度较短的数组)被视为 NULL。Missing values (in shorter length arrays) are treated as null.

返回Returns

根据条件数组的相应值,从 IfTrue 或 IfFalse [array] 值中获取的值组成的动态数组 。Dynamic array of the values taken either from the IfTrue or IfFalse [array] values, according to the corresponding value of the Condition array.

示例Example

print condition=dynamic([true,false,true]), l=dynamic([1,2,3]), r=dynamic([4,5,6]) 
| extend res=array_iif(condition, l, r)
conditioncondition ll rr resres
[true, false, true][true, false, true] [1, 2, 3][1, 2, 3] [4, 5, 6][4, 5, 6] [1, 5, 3][1, 5, 3]