Skip to main content

Field Projection in Collections

If a collection or list contains records, it is possible to extract one of the fields of the inner records directly on the parent list. The output of this operation is a list containing the selected field of each record.

For example:

Let
data = [
{ a: 1, b: "Hello" },
{ a: 2, b: "World!" }
]
in
data.b

Returns:

[
"Hello",
"World!"
]

This can be useful when trying to calculate several statistics on a certain field.

For example a query getting the min, max and average of the field year in a csv file with student information s3://rawlabs-public-test-data/students.csv can be calculated with:

let
data = Csv.InferAndRead("s3://rawlabs-public-test-data/students.csv")
in
{
min: Collection.Min(data.year),
max: Collection.Max(data.year),
average: Collection.Avg(data.year)
}