Power Query utility library with a functional twist
Power Query utility library with a functional twist
This module uses the extensibility provided by Data Connectors, so in order to use it you have to:
[My Documents]\Microsoft Power BI Desktop\Custom Connectors
directory/build
folder with all the *.mez files into the above folderIn order to extend the modules
Data Connector Projects
or *.pq files/src
. The Relese configuration of the build will copy these files into the /build
folder.For additional examples and explanations, please refer to the embeded documentation of each of the functions.
A function that does nothing but return the parameter supplied to it. Good as a default or placeholder function.
:: a -> a
Return a function which always returns a given value.
a -> b -> a
Reverse the order of arguments to a function of arity 2.
:: ((a, b) -> c) -> ((b, a) -> c)
Perform a right-to-left composition across a list of functions.
:: ((y -> z), (x -> y), ..., (a -> b)) -> a -> z
Perform a left-to-right composition across a list of functions.
:: ((a -> b), (b -> c), ..., (y -> z)) -> a -> z
Return a single item array containing the passed value.
:: a -> [a]
Takes a function f and a list of arguments, and returns a function g. When applied, g returns the result of applying f to the arguments provided initially followed by the argument list provided to g.
:: ((a, b, c, ..., n) -> x) -> [a, b, c, ...] -> ([d, e, f, ..., n] -> x)
Similar to _.Partial but instead of returning a function expecting a list of remaining arguments, provides a function expecting a final single argument in order to fully apply the initial function.
:: ((a, b, c, ..., n) -> x) -> [a, b, c, ...] -> (n -> x)
Takes a function f and a list of arguments, and returns a function g. When applied, g returns the result of applying f to the arguments provided to g followed by the argument list provided initially.
:: ((a, b, c, ..., n) -> x) -> [d, e, f, ..., n] -> ([a, b, c, ...] -> x)
Similar to PartialRight however accepts a single, final argument in order to fully apply the intial function.
:: ((a, b, c, ..., n) -> x) -> d, e, f, ..., n] -> (a -> x)
Curry a function so that arguments are supplied one at a time up until the specified arity is met at which point the original function will be invoked.
eg.Curry((a, b, c) => x) = (a) => (b) => (c) => x
:: number (* -> a) -> (* -> a)
Perform a left-associative reduction over a list.
:: (a b -> a) a -> [b] -> a
Perform a right-associative reduction over a list.
:: (a b -> b) -> b -> [a] -> b
Apply a transform to all elements of a list.
(a -> b) -> [a] -> [b]
Evaluate elements of a list against a predicate, returning a new list of the items which evaluated to true.
:: (a -> Boolean) -> [a] -> [a]
Given two lists, create a new list containing the result of appending b to a.
:: [a] [a] -> [a]
Add a single element to the head of a list and return a new list containing the merged result.
:: a -> [a] -> [a]
Provide the ability to chain sequences of internal table, record and list operations. The internal transform functions all take the object being transformed as parameter 0. To remove the need to assign intermediate variables this lifts that argument to be within a higher-order function allowing a sequence of operations to be performed. This sequence is defined as a list of lists, with element 0 containing the transform function and elements 1..n containing the arguments 1..n for that transform.
[(a -> b, x, y, ..n), (b -> c, x, y, ..n),...] -> a -> z
TransformDummyTable = _.ChainOperations({
{Table.SelectColumns, {"Col1", "Col2"}},
{Table.RenameColumns, {"Col1", "Id"}},
{Table.RenameColumns, {"Col2", "Alfa"}}
})(
#table({"Col1","Col2","Col3"},
{{1,"A","B"},
{2,"C","D"}})
)
The M functions used in this library have been inspired from the following repository