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

...

Info

NOTE: This function does not apply to relational database inputs, such as Hive or JDBC sources.

Info

NOTE: If the dataset is sourced from multiple files, a predictable original source row number cannot be guaranteed, and null values are returned.

Tip

Tip: If the source row information is still available, you can hover over the left side of a row in the data grid to see the source row number in the original source data.

D s

D s
snippetBasic

Derive Example:


d-lang-code

derive type:single value:SOURCEROWNUMBER() as:'OriginalRowNums'

...

syntax

sourcerownumber()


Output: Returns the source row number for each row as it appeared in the original data.

Sort Example:

d-

...

trans
RawWrangletrue
Typestep
WrangleTextsort order:

...

sourcerownumber()
p01NameSort by
p01Valuesourcerownumber()
SearchTermSort rows

Output: Rows in the dataset are re-sorted according to the original order in the dataset.

...


d-
code
trans
RawWrangletrue
p03Valuesourcerownumber() > 101
Typestep
WrangleTextdelete row:
SOURCEROWNUMBER
sourcerownumber() > 101
p01NameCondition
p01ValueCustom formula
p02NameType of formula
p02ValueCustom single
p03NameCondition
p04ValueDelete matching rows
p04NameAction
SearchTermFilter rows

Output: Deletes the rows in the dataset that were after row #101 in the original source data.

...

CustIdFirstNameLastNameCityStateLastOrder
1001SkipJonesSan FranciscoCA25
1002AdamAllenOaklandCA1099
1003DavidWigginsOaklandMI125.25
1004AmandaGreenDetroitMI452.5
1005ColonelMustardLos AngelesCA950
1006PaulineHallSagninawMI432.22
1007SarahMillerCheyenneWY724.22
1008TeddySmithJuneauAK852.11
1009JoelleHigginsSacramentoCA100


TransformTransformation:

Initially, you want to review your list of orders by last name.

d-

...

trans
RawWrangletrue
Typestep
WrangleTextsort order:LastName
p01NameSort by
p01ValueLastName
SearchTermSort rows

During your review, you notice that two customer orders are no longer valid and need to be removed. They are:

...

You might hover over the left side of the screen to reveal the row numbers. You select the row numbers for each of these rows, and a delete suggestion is provided for you. When you click Modify, you see the following transformtransformation: 

d-

...

trans
RawWrangletrue
p03Valuein(sourcerownumber(), [2,7])
Typestep
WrangleTextdelete row:

...

in(

...

sourcerownumber(), [2,7])
p01NameCondition
p01ValueCustom formula
p02NameType of formula
p02ValueCustom single
p03NameCondition
p04ValueDelete matching rows
p04NameAction
SearchTermFilter rows

The above checks the results of the SOURCEROWNUMBER sourcerownumber function, which returns the original row order for the selected rows. If a selected row matches values in the [2,7] array of row numbers, then the row is deleted.

...