each expression defines an anonymous function with one parameter whose name is the underscore (_). each [XYZ] is equal to _[XYZ] which is equal to (_) => _[XYZ]. { 123457, 123457 }. let
incr = each _ + 1,
incr_ = (_) => _ + 1, // same thing as above
get_fld = each _[FLD],
get_fld_ = (_) => _[FLD], // same thing as above
REC = [
ABC = "abcdef",
FLD = 123456
]
in
{
incr (get_fld (REC)),
incr_(get_fld_(REC))
}
[X] is a shorthand for _[X], an each expression that accesses a record-field can further be abbreviated like so (which evaluates to "Hello world"): let
get_fld = each [txt],
REC = [
num = 42,
txt = "Hello world"
]
in
get_fld(REC)
each expression shines for example when using together with List.Select. List.Select is a function that finds elements of a list that possess a certain characteristics. This characteristics is evaluated with the second parameter of List.Select which expects a function with one parameter. If this function returns true, the element is retained in the resulting list, otherwise, it is discarded: let
L = {
[ a = 1, b = 7, c = "A" ],
[ a = 3, b = 6, c = "B" ],
[ a = 9, b = 7, c = "C" ],
[ a = 8, b = 2, c = "D" ],
[ a = 2, b = 4, c = "E" ],
[ a = 4, b = 5, c = "F" ]
},
a_gt_b = List.Select(
L,
each [a] > [b]
)
in
Table.FromList(
a_gt_b,
Record.FieldValues, // Apply this function on each element in a_gt_b: it turns the record into a list
{ "col a", "col b", "col c" } // Name the columns
)