Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

D toc

Excerpt

Computes the number of elements in the arrays in the specified column, array literal, or function that returns an array.

  • This function calculates the number of elements in the outer layer of an array. If your array is nested, the count of inner elements is not factored.
  • If a row contains a missing array, the returned value is 0. If it contains a value that is not recognized as an array, the returned value is blank.

D s
snippetBasic

Array literal reference example:

D code

derive type:single value:ARRAYLEN([A,B,C,D])

Output: Generates the count of elements in the array, which is 4

Column reference example:

D code

derive type:single value:ARRAYLEN([myValues]) as:'length_myValues'

Output: Generates the new length_myValues column containing the count of elements in the myValues column.

Array function example:

D code

derive type:single value:ARRAYLEN(concat([colA,colB])) as:'length_myValues'

Output: Generates the new  length_myValues  column containing the count of elements in the array returned from concatenating colA and colB

D s
snippetSyntax

D code

derive type:single value:ARRAYLEN(array_ref)

ArgumentRequired?Data TypeDescription
array_refYstringName of Array column, Array literal, or function returning an Array to apply to the function

D s lang notes

array_ref

Name of the array column, array literal, or function returning an array whose elements you want to count.

  • Multiple columns and wildcards are not supported.

D s
snippetusage

 

Required?Data TypeExample Value
YesString (column reference or function) or array literalmyArray1

D s
snippetExamples

Example - Unnest an array

Include Page
EXAMPLE - Flatten and Unnest Transforms
EXAMPLE - Flatten and Unnest Transforms

D s also
labelnested