Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version next

...

D s
snippetBasic

Numeric literal example:

D code

derive type:single value: RANGE(0,3,1 ) as: 'threeSteps'

...

Output: Returns the following array:

Code Block
[0,1,2]

Column reference example:

D code

derive type:single value: RANGE(0,MaxValue,stepValue) as: 'mySteps'

...

Output: Returns an array of values from zero to the value in the MaxValue column stepping by the stepValue column value. 

D s
snippetSyntax

D code

derive type:single value: RANGE(column_integer_start, column _integer_end, column_integer_step)


ArgumentRequired?Data TypeDescription
column_integer_startYstring or integerName of column or Integer literal that represents the start of the range
column_integer_endYstring or integerName of column or Integer literal that represents the end of the range
column_integer_stepYstring or integerName of column or Integer literal that represents the steps in integers between values in the range

...

  • Missing input values generate missing results.
  • Multiple columns and wildcards are not supported.

D s
snippetusage

 


Required?Data TypeExample Value
YesInteger0

...

TimestampErrors
02/16/16 15:31["Unable to connect","File not found","Proxy down","conn. timeout"]
02/16/16 15:30[]
02/16/16 15:29["Access forbidden","Invalid password"]

TransformTransformation:

You can use the following steps to break out the array values into separate rows. The following transform generates a column containing the number of elements in each row's Errors array.

d-

...

trans
RawWrangletrue
p03Value'arraylength_Errors'
Typestep
WrangleTextderive type:single value:

...

arraylen(Errors) as:'arraylength_Errors'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valuearraylen(Errors)
p03NameNew column name
SearchTermNew formula

This transform deletes rows that contain no errors:

d-

...

trans
RawWrangletrue
p03Value(arraylength_Errors == 0)
Typestep
WrangleTextdelete row:(arraylength_Errors == 0)
p01NameCondition
p01ValueCustom formula
p02NameType of formula
p02ValueCustom single
p03NameCondition
p04ValueDelete matching rows
p04NameAction
SearchTermFilter rows

For the remaining rows, you can generate a column containing an array of numbers to match the count of error messages:

d-

...

trans
RawWrangletrue
p03Value'range_Errors'
Typestep
WrangleTextderive type:single value:

...

range(0,arraylength_Errors,1) as:'range_Errors'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valuerange(0,arraylength_Errors,1)
p03NameNew column name
SearchTermNew formula

You can then use the ARRAYZIP function to zip together the two arrays into a single one:

d-

...

trans
RawWrangletrue
p03Value'zipped_Errors'
Typestep
WrangleTextderive type:single value:

...

arrayzip([range_Errors,Errors]) as:'zipped_Errors'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valuearrayzip([range_Errors,Errors])
p03NameNew column name
SearchTermNew formula

The unnest transform uses the values in an array column as key values to break out rows in your dataset:

d-

...

trans
RawWrangletrue
Typestep
WrangleTextunnest col:zipped_Errors
p01NameColumn
p01Valuezipped_Errors
SearchTermUnnest Objects into columns

You might rename the above as individual_Errors. To clean up your dataset, you can now delete the following columns:

...