Coder Social home page Coder Social logo

powerqueryfunctional's Introduction

PowerQueryFunctional

Power Query utility library with a functional twist

PowerBI

Quickstart

This module uses the extensibility provided by Data Connectors, so in order to use it you have to:

  1. Create a [My Documents]\Microsoft Power BI Desktop\Custom Connectors directory
  2. Enable the Custom data connectors preview feature in Power BI Desktop (under File | Options and settings | Custom data connectors)
  3. Copy the the contents of /build folder with all the *.mez files into the above folder
  4. Restart Power BI Desktop

For developers

In order to extend the modules

  1. Install the Power Query SDK from the Visual Studio Marketplace
  2. Edit the existing Data Connector Projects or *.pq files
  3. Build the solution The deployable *.mez files will be located in the Debug folder of each module under /src. The Relese configuration of the build will copy these files into the /build folder.

Functions

For additional examples and explanations, please refer to the embeded documentation of each of the functions.

_.Identity

A function that does nothing but return the parameter supplied to it. Good as a default or placeholder function.

:: a -> a

_.Const

Return a function which always returns a given value.

a -> b -> a

_.Flip

Reverse the order of arguments to a function of arity 2.

:: ((a, b) -> c) -> ((b, a) -> c)

_.Compose

Perform a right-to-left composition across a list of functions.

:: ((y -> z), (x -> y), ..., (a -> b)) -> a -> z

_.Pipe

Perform a left-to-right composition across a list of functions.

:: ((a -> b), (b -> c), ..., (y -> z)) -> a -> z

_.Of

Return a single item array containing the passed value.

:: a -> [a]

_.Partial

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)

_.Partial1 =

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)

_.PartialRight

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)

_.PartialRight1

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 =

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)

_.Foldl

Perform a left-associative reduction over a list.

:: (a b -> a) a -> [b] -> a

_.Foldr

Perform a right-associative reduction over a list.

:: (a b -> b) -> b -> [a] -> b

_.Map

Apply a transform to all elements of a list.

(a -> b) -> [a] -> [b]

_.Filter

Evaluate elements of a list against a predicate, returning a new list of the items which evaluated to true.

:: (a -> Boolean) -> [a] -> [a]

_.Combine

Given two lists, create a new list containing the result of appending b to a.

:: [a] [a] -> [a]

_.Prepend

Add a single element to the head of a list and return a new list containing the merged result.

:: a -> [a] -> [a]

_.ChainOperations

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"}})
       )

References

The M functions used in this library have been inspired from the following repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.