Power Query Reference
website·Indexed 32 days ago
https://powerquery.io/Technical documentation and syntax reference for Power Query functions, including comprehensive guides for Table operations (transformation, construction, and membership), Number conversions, and data accessing functions.
What's inside Power Query
- The Power Query M formula language is a functional, case-sensitive language similar to F#, optimized for building flexible data mashup queries. It is utilized across several Microsoft products, including Power BI Desktop, Excel, and Analysis Services.
Overview of PQDriverless binary connectors
PQDriverless is an open-source package (Apache-2.0) of pure M readers for binary file formats. It allows Power BI and Excel to decode binary files directly at query time using
Binary.Range,BinaryFormat.*, andBinary.Decompress, removing the requirement for machine-level driver installations (ODBC, OLE DB, etc.).Because these are plain M source scripts, they work in Power BI Desktop, Excel, dataflows, and the Power BI Service. If the source file is hosted on SharePoint, OneDrive, or Blob storage, the need for an on-premises data gateway is also eliminated.
Understand the PQDriverless function contract
PQDriverless provides a set of open-source, pure M readers for binary file formats that do not require ODBC or OLE DB drivers. Every connector in the library follows a consistent function signature: it accepts a binary source and an optional record of options, returning a table.Reader.Function( source as binary, optional options as record ) as tableRetrieve Planview Enterprise Architecture data using Troux.CustomFeed
TheTroux.CustomFeedfunction allows you to import data from a Planview Enterprise Architecture account into a table. It requires the account URL and a specific query string to filter the returned data.Troux.CustomFeed( url as text, query as text ) as tableRetrieve Access database metadata
You can extract metadata about the Access file, such as the version, format, and creation date, by usingValue.Metadataon the result of theAccessReader.Databasefunction. Available metadata keys includeAccess.Version,Access.Format, andAccess.CreationDate.let Db = AccessReader.Database(File.Contents("C:\data\example.accdb")) in Value.Metadata(Db)[Access.Version]Retrieve Planview Enterprise Architecture data using Troux.Feed
TheTroux.Feedfunction connects to a Planview Enterprise Architecture account and returns the account's data as a table. To use this function, you must provide the URL of your Planview Enterprise Architecture account as a text string.Troux.Feed( url as text ) as tableUnderstand the output of SoftOneBI.Contents
When callingSoftOneBI.Contents(), the resulting table contains metadata about the datalake objects. The output includes columns such asName,ItemKind,ItemName,Data(which contains the actual table content), andIsLeaf.#table({"Name"}, {"ItemKind"}, {"ItemName"}, {"Data"}, {"IsLeaf"}, {{"Companies"}, {"Table"}, {"Table"}, {"Table"}, {"true"}})Retrieve table partitioning information using Table.PartitionValues
UseTable.PartitionValuesto get information about how a table is partitioned. The function returns a table where each column represents a partition column from the original table, and each row represents a specific partition within that table.Table.PartitionValues( table as table ) as tableRetrieve LEAP data using LEAP.Contents
TheLEAP.Contentsfunction returns a table containing relevant LEAP data. This table typically includes metadata about the available data folders and items, such as their names, keys, and types.LEAP.Contents()Read SQLite databases using Sqlite3.Database
The
Sqlite3.Databasefunction is part of the PQDriverless library and allows Power Query to parse SQLite file formats (.sqlite,.db,.db3) directly from binary data. This eliminates the need for machine-level ODBC driver installations, making it compatible with locked-down desktops, Power BI Gateways, and the Power BI Service.It returns a navigation table containing the tables found within the SQLite database file.
Sqlite3.Database( source as binary, optional options as record ) as tableExample usage of Text.PadEnd for string padding
The following examples demonstrate how to pad a string to a length of 10 characters using both the default space character and a custom character ('|').// Pad with default spaces to 10 characters Text.PadEnd("Name", 10) // Result: "Name " // Pad with a custom character "|" to 10 characters Text.PadEnd("Name", 10, "|") // Result: "Name||||||"Example: Create an open record type from a closed record type
This example demonstrates how to transform a closed record typetype [ A = number]into an open record typetype [A = number, ...], which indicates that the record must have field A as a number but may contain other fields.// Input: Closed record type Type.OpenRecord(type [A = number]) // Result: Open record type // type [A = number, ...]