Muokkaa

Jaa


array_shift_right()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Shifts the values inside a dynamic array to the right.

Syntax

array_shift_right(array, shift_count [, default_value ])

Learn more about syntax conventions.

Parameters

Name Type Required Description
array dynamic ✔️ The array to shift.
shift_count int ✔️ The number of positions that array elements are shifted to the right. If the value is negative, the elements are shifted to the left.
default_value scalar The value used for an element that was shifted and removed. The default is null or an empty string depending on the type of elements in the array.

Returns

Returns a dynamic array containing the same amount of the elements as in the original array. Each element has been shifted according to shift_count. New elements that are added instead of the removed elements have a value of default_value.

Examples

Shifting to the right by two positions:

print arr=dynamic([1,2,3,4,5])
| extend arr_shift=array_shift_right(arr, 2)

Output

arr arr_shift
[1,2,3,4,5] [null,null,1,2,3]

Shifting to the right by two positions and adding a default value:

print arr=dynamic([1,2,3,4,5])
| extend arr_shift=array_shift_right(arr, 2, -1)

Output

arr arr_shift
[1,2,3,4,5] [-1,-1,1,2,3]

Shifting to the left by two positions by using a negative shift_count value:

print arr=dynamic([1,2,3,4,5])
| extend arr_shift=array_shift_right(arr, -2, -1)

Output

arr arr_shift
[1,2,3,4,5] [3,4,5,-1,-1]