Excerpt |
---|
Computes the index at which a specified element is first found within an array. Indexing is left to right. |
- Leftmost index value is
0
. - If the element is not found, null is returned.
- For right-to-left searching, use ARRAYRIGHTINDEXOF.
- If only one element exists in the array, both functions return the same value.
- For more information, see ARRAYRIGHTINDEXOF Function.
Array literal reference example:
D lang syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | derive type:single value:arrayindexof(["A","B","C","D"],"C") |
---|
|
arrayindexof(["A","B","C","D"],"C") |
Output: Returns the index of the element "C" in the array, which is 2
in an 0-based index.
Column reference example:
D lang syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | derive type:single value:arrayindexof([myValues],myElement) as:myIndexOfmyValues' |
---|
|
arrayindexof([myValues],myElement) |
Output: Returns the index in the myValues
arrays for the elements listed in the myElement
column.
D lang syntax |
---|
RawWrangle | true |
---|
Type | syntax |
---|
showNote | true |
---|
WrangleText | derive type:single value:arrayindexof(array_ref,my_element) |
---|
|
arrayindexof(array_ref,my_element) |
Argument | Required? | Data Type | Description |
---|
array_ref | Y | array or string | Name of Array column, Array literal, or function returning an Array to apply to the function |
my_element | Y | any | The element to locate in the array |
array_ref
Name of the array column, array literal, or function returning an array whose element you want to locate.
- Multiple columns and wildcards are not supported.
Required? | Data Type | Example Value |
---|
Yes | String (column reference or function) or array literal | myArray1 |
my_element
Element literal that you wish to locate in the array. It can be a value of any data type.
Required? | Data Type | Example Value |
---|
Yes | Any | "1st" |
Example - Computing points based on position of finish
Include Page |
---|
| EXAMPLE - ARRAYINDEXOF and ARRAYRIGHTINDEXOF Functions |
---|
| EXAMPLE - ARRAYINDEXOF and ARRAYRIGHTINDEXOF Functions |
---|
|