Fact-checked by Grok 2 weeks ago

Power Query

Power Query is a data connectivity and data preparation technology developed by that enables end users to discover, connect to, combine, and refine data from a wide range of sources into cohesive datasets for analysis and reporting. It functions as an extract, transform, and load (ETL) engine, featuring a called the Power Query Editor for intuitive data shaping and the M formula language for advanced scripting and automation of transformations. Originally introduced as a free add-in for Excel 2010 and 2013 on Windows, Power Query allowed users to import and transform external data without complex coding. It was later integrated natively into Excel 2016 and subsequent versions as the "Get & Transform" feature on the Data tab, becoming the primary tool for data import and cleaning in Microsoft 365. Support expanded to Excel for Mac starting in 2019, with capabilities for refreshing data from files like TXT, CSV, and JSON, as well as databases such as SQL Server. Key features include connectivity to diverse sources—such as files (Excel, CSV, XML), databases (SQL Server, ), web services, Azure services, and cloud platforms—and a step-by-step transformation process that records operations like filtering rows, removing columns, changing data types, merging tables, and pivoting data for repeatability and refreshability. The tool supports loading transformed data directly into worksheets, the Excel Data Model, or other destinations, helping business users who typically spend up to 80% of their time on data preparation. Power Query is embedded across the ecosystem, including for visualizations, Analysis Services for multidimensional modeling, for data storage in Power Apps, and Analytics for cloud-based analytics, ensuring consistent data handling workflows. It also powers cloud experiences like dataflows in Power BI service and Microsoft Fabric, enabling scalable, shared data preparation in collaborative environments. This integration makes Power Query essential for self-service , allowing non-technical users to handle large volumes of structured and efficiently.

Introduction

Definition and Purpose

Power Query is a data connectivity and preparation developed by , functioning as an extract, transform, and load (ETL) that allows users to connect to a wide of data sources, clean and shape the data, and load it into analysis tools such as Excel and Power BI. This graphical interface-based tool supports over 350 transformations and connects to hundreds of data sources, enabling seamless data import and reshaping without requiring deep technical expertise. The core purpose of Power Query is to empower business users and analysts to perform complex data transformations efficiently, helping to reduce the time spent on data preparation tasks, which can account for up to 80% of a business user's time. Originally introduced as a free add-in for earlier versions of Excel, it has evolved into a native feature within , enhancing accessibility across platforms like Excel for Windows, , and Power BI Desktop and Service. At its foundation, Power Query relies on the M formula language for defining transformations, which can be edited advancedly while keeping the primary visual and intuitive. Common use cases include merging datasets from multiple sources, such as combining sales data from a database with customer information from a , and handling messy data by removing duplicates, filling missing values, or filtering irrelevant rows and columns to prepare it for reporting or . These capabilities make Power Query essential for creating repeatable and refreshable queries that update automatically as source data changes, streamlining workflows in data-driven .

Key Features and Benefits

Power Query offers a that enables users to perform data transformations intuitively without writing code, supporting over 350 transformation types for cleaning, reshaping, and combining data from various sources. This interface automatically detects and suggests data types during import, streamlining the initial data shaping process and reducing errors in subsequent analyses. Additionally, it provides connectivity to hundreds of data sources through built-in connectors, allowing seamless integration with databases, files, web services, and cloud platforms like and BigQuery. A core capability is non-destructive editing, where all transformations are recorded as sequential "Applied Steps" that can be reviewed, modified, or reverted at any time, preserving the original . The primary benefits of Power Query include significantly reducing the time required for data preparation by automating repetitive tasks such as filtering, merging, and pivoting, enabling analysts to focus more on insights rather than manual manipulation. This leads to reproducible workflows, as the Applied Steps ensure consistent transformations across datasets and users, facilitating reliable reporting in tools like Excel and Power BI. In enterprise settings, it supports collaboration by allowing shared queries and dataflows in the Power BI service, where teams can build upon each other's preparations without duplicating efforts. Power Query handles large datasets scalably through features like query folding, which pushes transformations back to the data source to minimize processing overhead and improve performance. It integrates data profiling tools for column quality, distribution, and statistics, providing tools to identify issues like missing values or outliers early in the workflow. For data privacy, on-premises deployment options via gateways ensure sensitive information remains secure without cloud exposure. Compared to traditional ETL tools like (SSIS), Power Query adopts a low-code approach with its visual editor, making it more accessible for business users and faster for ad-hoc transformations, whereas SSIS relies on scripted packages better suited for complex, scheduled enterprise pipelines. The M language underpins these features, allowing advanced customizations when needed beyond the graphical interface.

History

Origins and Early Development

Power Query originated as a project within SQL Azure Labs, initially codenamed "Data Explorer," with its first public announcement occurring at the SQL Pass Summit in October 2011. This early incarnation was designed as a cloud-based service to facilitate data exploration and mashup capabilities, allowing users to connect to and transform data from diverse sources such as SQL Server, Excel files, and web pages directly in a environment. The tool's development drew from 's internal data integration efforts, emphasizing mashup technologies to combine heterogeneous data without requiring extensive coding. A core objective of Data Explorer was to democratize data access and analysis, empowering non-technical "power users" to perform self-service extract, transform, and publish (ETP) operations on varied data types. This vision was inspired by paradigms, which informed the creation of the underlying M language—a declarative, that prioritized composable transformations and reproducibility. By focusing on intuitive data shaping rather than procedural scripting, the project aimed to bridge the gap between IT-managed data pipelines and end-user needs, particularly for creating custom OData feeds from blended sources. Initial prototypes emerged in late 2011 as web-centric tools for exploratory data work, with early previews released in January 2012 via SQL Azure Labs, including both cloud-hosted and desktop client options for testing. Beta testing throughout 2012 emphasized web data extraction and integration, enabling users to pull structured content from online sources and apply transformations iteratively through a visual interface. These phases refined the tool's ability to handle real-world data mashups, setting the foundation for its evolution into a desktop add-in while retaining the M language as its scripting backbone. In 2013, it was renamed Power Query to align with Microsoft's Power family of tools.

Major Milestones and Product Integrations

Power Query was initially released in July 2013 as a free add-in for Excel 2010 and 2013, having been renamed from its preview codename "Data Explorer" to emphasize its focus on self-service and data discovery. This add-in simplified data import, transformation, and mashup capabilities, making advanced ETL processes accessible to non-technical users without requiring programming expertise. In September 2015, Power Query achieved native integration into Excel 2016 as "Get & Transform," embedding its engine directly into the application and expanding its reach to a broader user base within the Microsoft Office suite. By 2018, Microsoft unified the branding across its ecosystem, reverting to "Power Query" as the official technology name while retaining "Get & Transform" for the Excel interface, which facilitated consistent development and updates. That same year, Power Query was integrated into the Common Data Service (now Microsoft Dataverse), enabling seamless data ingestion, preparation, and loading into cloud-based entity stores for Power Apps and Dynamics 365. A key enterprise milestone occurred in 2017 with the addition of Power Query to SQL Server Analysis Services (SSAS) tabular models at compatibility level 1400, introducing the modern Get Data experience and support for M language expressions to handle complex data transformations directly within SSAS projects. This integration bridged self-service analytics with on-premises data warehousing, allowing SSAS developers to leverage Power Query's query builder for enhanced data sourcing and folding. Recent advancements from 2024 to 2025 have further solidified Power Query's role in Microsoft's AI-driven ecosystem. In June 2024, Power Query templates entered preview in Power BI and Microsoft Fabric, providing reusable scripts with metadata for streamlined dataflow creation and project portability across environments. Enhancements to Copilot integration enabled natural language-guided transformations in Power BI, such as automated query generation and data shaping; in September 2025, Copilot in Dataflow Gen2 reached general availability, supporting natural language for generating and explaining transformations, with iterative improvements boosting accuracy for semantic models and reports. Simultaneously, Power Query expanded within Microsoft Fabric, powering unified data pipelines in data engineering workloads like lakehouses and warehouses, which support hybrid cloud-on-premises scenarios through seamless connectivity to OneLake and external sources. These milestones mark Power Query's evolution from a standalone Excel add-in to a core ETL component of the Power Platform, fostering scalable, low-code data workflows that integrate disparate sources while maintaining consistency via the M language across versions. This shift has enabled organizations to build hybrid architectures, combining on-premises SSAS models with cloud services like and Fabric for end-to-end analytics.

User Interface and Workflow

Power Query Editor Interface

The Power Query Editor provides a for data preparation, allowing users to connect to data sources, preview content, and apply transformations visually. It is accessible in through the Data tab by selecting Get Data, which launches the editor after source selection, or in Power BI Desktop via the Transform Data button on the Home tab, initiating the editor directly from the report view. Upon entry, users encounter an initial data preview via the dialog, where they select tables or sheets from the source for loading into the editor. The editor's layout centers on a at the top, featuring , Transform, and tabs that organize commands for common actions such as connecting to new sources, applying filters, or toggling display modes. Below the lies the Queries pane on the left, which lists all loaded queries and enables management tasks like renaming, duplicating, or grouping them for organization. The central area displays the Data preview grid, a tabular view of the current query's data, allowing real-time inspection as changes are made. Additional panels enhance interaction: the Formula bar, visible when enabled via the View tab, shows M expressions for the selected step, facilitating quick edits to the underlying code. The Properties pane, accessible by right-clicking a query in the Queries pane, displays settings such as query name and description, while error diagnostics appear in the at the bottom, reporting details like row counts, execution time, or issues encountered during refresh. For advanced customization, the Advanced Editor dialog, opened from the View tab or Home ribbon, provides a full view of the query's code for manual scripting. Navigation within the editor includes the Diagram view, introduced in November 2020 updates to Power Query Online, which visualizes query dependencies as a flowchart to illustrate dataflow relationships and transformations. The Schema view, available in Power Query Online, offers a focused interface for schema-level operations such as managing columns and data types. This view aids in understanding complex query structures without delving into code. The Applied Steps pane on the right records sequential changes applied to the data, serving as a visual audit trail. Users can reference the M language briefly through the Advanced Editor for custom modifications when visual tools are insufficient.

Transformation Steps and Applied Steps

In Power Query, the Applied Steps list serves as a sequential record of all transformations applied to a , enabling users to track, review, and manage the data shaping process. This list appears in the Query Settings pane and includes default steps such as "," which connects to the data origin, "Changed Type," which adjusts column data types, and "Removed Columns," which eliminates unnecessary fields. Each step represents a specific operation, and selecting one in the list previews the at that point in the workflow, facilitating step-by-step verification. Users can manage these steps dynamically to refine transformations. For instance, steps can be deleted by right-clicking and selecting the option or using the X icon, which removes the step and any dependent subsequent ones if needed. Reordering is possible via drag-and-drop or right-click menu to move a step before or after another, ensuring logical sequence. Editing settings for a step, such as modifying a criterion or source , is available through the right-click menu where applicable, while renaming provides clarity for complex queries. Additionally, inserting a new step after a selected one or extracting previous steps into a new query supports modular development. This management allows iterative adjustments without restarting the entire process. Power Query offers a wide range of built-in transformation options, over 350 in total, categorized under tabs like , , and Add Column in the editor . Common operations include filtering rows to retain only relevant records based on conditions like date , splitting columns to separate delimited values into multiple fields, and pivoting or unpivoting to switch between columnar and row-based formats for . Merging queries combines datasets from multiple sources using join types such as inner or left outer, while appending stacks tables vertically for unified views. These transformations are applied sequentially, with each addition automatically generating an entry in the Applied Steps list. The workflow emphasizes iterative development, where users preview data changes in real-time after each step and apply modifications directly in the Power Query Editor interface. This supports branching through query references, where a new query can reference an existing one at a specific step, enabling parameterized variations like dynamic date filters without duplicating base transformations. Upon completion, steps are committed via the Close & Apply command, loading the shaped data into the host application. Each applied step corresponds to underlying M language code, though edits are primarily graphical. Error resolution in the Applied Steps focuses on diagnosing and addressing step failures to maintain query . When a step encounters an issue, such as a missing column or inaccessible source, a error pane displays the reason (e.g., ), message, and details, preventing full query loading until fixed. Users resolve these by reviewing steps sequentially, adjusting parameters like file paths for .NotFound errors, or removing problematic steps. Diagnostics tools, accessible via the editor, provide deeper insights into evaluation , while cell-level issues like mismatches can be handled by replacing with nulls or defaults directly in the preview. Refresh mechanisms update the dataset upon source changes, re-evaluating steps from the beginning, but persistent require targeted fixes to avoid propagation.

The M Language

Syntax and Core Concepts

The Power Query M language is a functional, case-sensitive programming language similar to F#, specifically designed for creating data mashups by transforming and combining data from various sources, and it employs to optimize performance by deferring computations until necessary. As a higher-order functional language, M treats functions as mappings from input values to output values, enabling composable operations that align with data transformation workflows. At its core, M revolves around expressions that evaluate to values, where every syntactic construct produces a computable result, fostering a declarative style suited to data tasks. Primary value types in M include lists for ordered collections, records for named fields, and tables as structured containers, which serve as the foundational building blocks for mashup operations. Functions are first-class citizens, meaning they can be passed as arguments, returned from other functions, or stored in variables, allowing for reusable and modular code in . Basic syntax in M begins with an invocation operator = to start a query expression, such as = Table.SelectRows(previousStep, each [Column] > 5), which applies transformations to prior results. Scoping is managed through let and in constructs, where let defines intermediate variables or steps and in specifies the final output, promoting readable, step-by-step query building. The language supports error-tolerant operations, such as handling nulls or failures gracefully without halting execution, which enhances robustness in data pipelines. Let expressions form a key construct for this scoping mechanism. M's design prioritizes readability for non-programmers engaged in data preparation, using intuitive syntax that mirrors natural data manipulation steps, while offering extensibility through built-in libraries like Table.FromRecords for converting structures into tables. This balance supports seamless integration with the Power Query , where UI actions generate underlying M code automatically.

Let Expressions and Functions

The let expression serves as the foundational construct for defining Power Query M queries, enabling the modular construction of data transformations by assigning intermediate results to named variables before yielding a final output. This structure promotes readability and reusability, particularly in data pipelines where multiple steps are chained together. The syntax of a let expression follows the form let Variable1 = expression1, Variable2 = expression2, ... in finalExpression, where each variable binds the result of an expression, and the in clause specifies the output, typically the last variable or a derived value. For instance, a simple let expression to load and filter a CSV file might appear as:
let
    Source = Csv.Document("OrderID,Price\n1,100\n2,50\n3,75", [Delimiter=",", Columns=2, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    Filtered = Table.SelectRows(Source, each [Price] > 60)
in
    Filtered
This loads the CSV data into a table via Csv.Document and applies row filtering using Table.SelectRows, returning only rows where the Price exceeds 60. For more complex pipelines, nested let expressions can encapsulate sub-queries within variables, allowing hierarchical organization of transformations. M includes a rich library of built-in functions that integrate seamlessly within let expressions for common operations. The Table.Group function performs aggregation by grouping rows on specified keys and applying aggregators to columns, such as summing values; for example:
let
    Source = Table.FromRecords({
        [CustomerID = 1, Price = 20],
        [CustomerID = 1, Price = 10],
        [CustomerID = 2, Price = 30]
    }),
    Aggregated = Table.Group(Source, {"CustomerID"}, {{"TotalPrice", each List.Sum([Price]), type number}})
in
    Aggregated
This groups by CustomerID and computes the sum of Price for each group. For string manipulations, Text.Combine joins a list of text values with an optional separator, useful in data cleaning tasks like concatenating fields. Temporal data handling relies on DateTime functions, such as DateTime.From to construct datetime values from date and time components, or DateTime.ToText to format them as strings for reporting. Users can define custom functions in M using the lambda syntax (parameters) => expression, which creates invocable mappings akin to built-in ones and can be assigned to variables in let expressions for reuse. A basic example defines a function to add a fixed value to a number:
let
    AddFive = (x as number) => x + 5,
    Result = AddFive(10)
in
    Result
This yields 15 and demonstrates how custom functions enhance modularity in queries.

Data Handling in M

Data Types and Assertions

Power Query's M language employs a that classifies values to ensure and facilitate transformations. Primitive types form the foundational building blocks, including type text for strings, type number for numeric values (such as decimals or integers), type datetime for date and time combinations, and type logical for values (true or false). These types support nullable variants, denoted as type nullable text or similar, which accommodate the null value alongside the base type, allowing for optional or missing without disrupting queries. The type null primitive specifically classifies the absence of a value. Structured types in M build upon primitives to represent complex data arrangements. Records are defined with field-specific types, such as type [Name = text, Age = number], enabling named key-value pairs that can be open (allowing extra fields) or closed. Lists specify an item type, for example type list or more precisely type {number} for collections of numbers, maintaining order while permitting heterogeneous elements unless constrained. Tables, akin to structured datasets, declare column schemas like type table [Column1 = text, Column2 = number], supporting row-based operations and optional key definitions for uniqueness. These structured types enhance data modeling by enforcing schemas during transformations. Assertions in M enforce type compatibility, preventing errors from mismatched data. The as operator performs type ascription, such as 42 as number, which returns the value if compatible or raises an Expression.Error if not, as in "abc" as number. For non-enforcing checks, the is operator tests compatibility, returning a logical value: 42 is number yields true, while "abc" is number yields false. Functions like Value.Type(value) retrieve a value's type, aiding in dynamic assertions, and constructs such as try expression otherwise alternative handle potential type-related errors gracefully by providing fallbacks. Null values are compatible with any, null, or nullable types under these checks. Type propagation in Power Query combines automatic inference with manual controls. In the user interface, types are inferred from source schemas for structured data or sampled from the first 200 rows for unstructured sources, adjustable via options like "Detect data type." Manually, M code applies types using functions such as Table.TransformColumnTypes(sourceTable, {{"Column", type text}}) to enforce schemas across columns, or Value.ReplaceType(value, type number) for individual values with minimal validation. Locale settings influence inference, such as interpreting date formats differently between regions. This propagation ensures consistent data flow, often documented briefly in let expressions for clarity.

Comments and Error Handling

In the Power Query M language, comments serve as documentation tools that are ignored by the evaluator during query execution, allowing developers to annotate code without affecting runtime behavior. Single-line comments begin with two forward slashes (//) and extend to the end of the line, while multi-line comments are enclosed between /* and */ and can span multiple lines. These comment types are particularly useful for explaining complex transformation steps, such as custom function logic or data merging operations, to improve code maintainability in collaborative environments. Errors in M represent failures during expression evaluation, typically manifested as records that halt processing unless explicitly handled. Common error types include Expression.Error, which signals a general failure in evaluating an expression (e.g., invalid operations like ), and Conversion.Failed, which occurs during type conversions such as Number.ToText when the input cannot be properly transformed. These errors are structured as containing fields like Reason (specifying the error type, e.g., "Expression.Error"), Message (a descriptive , e.g., "We cannot convert the value to type Text"), and (additional diagnostic information, often or an error detail ). Error handling in M primarily relies on the try expression, which wraps a protected-expression and optionally includes an error-handler to manage failures gracefully. The basic syntax is try protected-expression otherwise default-expression, where successful evaluation returns the result of protected-expression, but an error triggers the return of default-expression (e.g., try Number.FromText("invalid") otherwise null returns null instead of propagating the Conversion.Failed error). For more advanced control, the catch clause can capture the error as a parameter: try protected-expression catch errorValue => customLogic, enabling inspection of the error record before deciding on a response. Custom errors can be raised using Error.Record to construct records with specified Reason, Message, and Detail fields, such as Error.Record("CustomError", "Invalid input detected", [Input = invalidValue]). Unhandled errors propagate upward through the query evaluation, potentially causing the entire step or query to fail, which underscores the importance of wrapping risky operations like data source accesses or type assertions. Best practices for error management in M include using comments to document anticipated error scenarios in complex let expressions, thereby aiding debugging and team reviews. For runtime logging, the Diagnostics.Trace function outputs trace messages at specified levels (e.g., Information, Warning, Error) when tracing is enabled, returning the input value unchanged to avoid disrupting query flow—e.g., Diagnostics.Trace(TraceLevel.Information, "Processing row: " & Text.From(rowIndex), value). Additionally, Query Diagnostics provides a built-in tracing tool in Power Query Editor or Power BI Desktop, capturing detailed evaluation logs during authoring or refresh to identify error sources, such as failed transformations in applied steps. Assertions can be referenced briefly for proactive prevention by validating inputs early, complementing reactive try handling.

Data Connectivity

Built-in Connectors

Power Query provides a wide array of built-in connectors that enable users to import data from diverse sources directly within applications like Power BI, Excel, and Power Apps. These connectors facilitate seamless connectivity to files, databases, web services, and cloud platforms without requiring custom coding, supporting a variety of data formats and protocols. As of October 2025, Power Query includes over 150 such connectors, categorized to cover common data ingestion scenarios. The connectors are grouped into primary categories, each tailored to specific data environments. For file-based sources, Power Query supports connectors for formats such as , Excel workbooks, files, PDF documents, and XML, allowing users to load structured or from local or network files. Database connectors target relational systems, including SQL Server, , , , and Azure SQL Database, enabling queries against tables, views, or stored procedures. Web connectors handle online data feeds, such as OData services, APIs, and platforms like or , often via URL-based access. Cloud connectors integrate with services like Azure Blob Storage, lists, , and Google BigQuery, supporting scalable storage and collaboration tools. Authentication for these connectors varies by category and source but commonly includes options like Basic authentication (username/password), OAuth 2.0 for secure token-based access, Windows integrated authentication for on-premises networks, and organizational accounts via . Users configure these during connection setup to ensure secure data retrieval, with some connectors supporting anonymous access for public sources. To use a built-in connector, users access the "Get Data" menu in the Power Query Editor or host application, select the desired connector from the list, and provide necessary parameters such as addresses, database names, file paths, URLs, or endpoints, followed by credential entry. This process generates an initial query that can be refined with transformations. Certain connectors, particularly those for on-premises databases or files, require an on-premises data gateway for cloud-based services like Power BI Service to enable refresh capabilities. While most built-in connectors are available in standard editions, some—such as the Exact Online Premium connector or advanced cloud integrations—necessitate a premium license for full functionality. Additionally, with query folding (which pushes transformations back to the source for efficiency) depends on the connector, though not all support live connections like DirectQuery. Gateway requirements apply to non-cloud sources in shared environments, potentially adding setup overhead.

Query Folding Mechanism

Query folding is an optimization mechanism in Power Query that enables the translation of data transformation steps written in the M language into native queries executed directly at the data source, thereby minimizing data transfer and leveraging the source's computational capabilities. This process occurs automatically when Power Query detects compatible steps, offloading evaluation to the source where possible, such as converting a operation into a SQL WHERE clause for relational databases. The mechanism analyzes the sequence of applied steps in a query, identifying those that can be folded back to the source, and combines them into a single native query before retrieving results. For instance, operations like selecting specific columns, sorting rows, or limiting row counts—such as keeping the top 10 rows from a large table—can be fully folded, resulting in the source returning only the processed subset of data. Similarly, filtering rows based on conditions, grouping data for aggregation, and performing joins between tables are often supported on foldable connectors, such as relational databases, where these translate to efficient SQL equivalents like SELECT with GROUP BY or INNER JOIN. Partial folding may occur if some steps are compatible while others are not, allowing initial transformations to execute at the source before subsequent ones in Power Query. Folding breaks when encountering non-foldable operations, such as custom M functions, complex calculations not native to the source, or transformations like certain text manipulations that require full data loading. Connectors that support folding, including those for SQL Server and , enable these optimizations, though support varies by data source capabilities. In the Power Query Editor interface, folding status is indicated by icons in the Applied Steps pane—accessible via the Query Settings view—such as a green icon for full folding up to a step, red for no folding, and yellow for runtime-determined folding. By reducing the volume of data transferred over the network and utilizing optimized source-side processing, query folding significantly enhances performance, particularly for large datasets where full loading could otherwise take minutes or longer; for example, a fully folded query on millions of rows might complete in seconds compared to hundreds of seconds without it. This efficiency is crucial for scalable data preparation in tools like Power BI, serving as a key alternative to modes like DirectQuery for certain workloads.

Advanced Features

DirectQuery Support

DirectQuery is a mode in Power BI that enables real-time querying of data sources without importing data into the model, contrasting with Import mode, which loads a of the data into Power BI for faster local processing. In DirectQuery, queries generated by reports or visuals are sent directly to the underlying data source each time the report is refreshed or interacted with, ensuring access to the most current data while keeping the dataset size minimal. This mode is particularly suited for scenarios where data volumes are large or change frequently, as it avoids the need for scheduled imports. To set up DirectQuery, users connect to a supported data source via the Get Data option in Power BI Desktop, selecting the DirectQuery connectivity mode during the connection process rather than Import. Once connected, the storage mode for tables is set to DirectQuery in the model's properties, and transformations in Power Query must be limited to those that support query folding—where steps are translated into native queries sent to the source—to prevent errors or performance degradation. Supported sources include relational databases such as SQL Server, Azure SQL Database, PostgreSQL, and Snowflake, as well as some multidimensional sources like SAP BW, though compatibility varies by connector. For on-premises sources, an on-premises data gateway is required to facilitate secure connections. The advantages of DirectQuery include near accuracy, the ability to work with large underlying datasets without importing them into the model, although individual queries and intermediate operations are limited to returning up to 1,000,000 rows in non- capacities (with higher limits configurable in ), and adherence to row-level security defined at the source. However, it introduces dependencies on the source system's performance and availability, potentially leading to higher during report interactions, and restricts advanced modeling features like automatic date hierarchies or complex measures that require imported data. Additionally, not all Power Query transformations are supported, as they must fold back to the source to avoid downloading entire datasets. As of 2025, enhancements to DirectQuery include improved performance optimizations in certain visuals (e.g., Zebra BI Tables) for handling hierarchies including ragged ones, and support for composite models, which allow mixing DirectQuery tables with or Direct Lake tables within the same semantic model to blend and cached data sources. Composite models enable relationships across different storage modes, such as linking live SQL Server data via DirectQuery to imported Excel files, providing flexibility for scenarios while maintaining query folding where possible. These updates, introduced in features like the May 2025 release, reduce load times for complex reports without altering the core live-querying behavior. Common use cases for DirectQuery involve building dashboards that require up-to-the-minute insights, such as sales metrics from operational databases or financial reports from systems, where data freshness outweighs the need for sub-second visual responsiveness.

Custom Functions and Connectors

Power Query allows users to extend its functionality through custom functions written in the M formula language, enabling reusable logic for data transformations. These functions are defined using a structure, where the function is assigned within the let block and invoked via the in clause, facilitating modular query building. For instance, a simple custom function to convert text to uppercase can be created as follows:
let
    UpperText = (input as text) => Text.Upper(input)
in
    UpperText
This function takes a text parameter and applies the built-in Text.Upper operation, promoting reusability across multiple queries. To develop custom functions, users access the Advanced Editor in the Power Query Editor interface, where they manually enter M code to define the function's parameters and body. Parameterization enhances flexibility; for example, a function processing a of values might accept both the list and a as inputs, allowing dynamic based on query . Once defined, the function appears in the Queries pane and can be invoked in subsequent steps, such as adding a custom column via the "Invoke Custom Function" option in the Add Column tab, passing column values as arguments to apply the logic row-wise. This approach supports complex scenarios like or aggregation without duplicating code. Custom connectors further extend Power Query by integrating with non-native data sources, such as proprietary APIs, using the Power Query SDK. Developed using the M formula language for defining schemas and logic, with optional .NET components for advanced features such as custom authentication, and supporting Web APIs for RESTful interactions, these connectors encapsulate authentication, navigation, and data retrieval mechanisms tailored to specific services. The SDK provides templates for common patterns, including OAuth 2.0 support and schema definition via M extension files (.pq), enabling seamless integration with sources like custom OData endpoints or internal databases. Development occurs in Visual Studio Code with the official Power Query SDK extension, which offers syntax highlighting, validation, and a test runner for simulating queries like ConnectorName.Contents(). Completed connectors are packaged as .mez files—a zipped archive containing the .pq definition, resources, and icons—for distribution. For proprietary APIs, developers define navigation tables and entity schemas in M, ensuring query folding where possible to optimize performance. Deployment involves placing the .mez file in the user's Custom Connectors directory (e.g., Documents\Microsoft Power BI Desktop\Custom Connectors) for local use in Power BI Desktop or Excel, with security settings adjusted to allow uncertified connectors. For enterprise scenarios, connectors are uploaded to the on-premises data gateway, enabling refresh in the Power BI service and Microsoft Fabric environments; this supports shared access across workspaces without per-user installation. Certification by Microsoft, involving signing with a trusted certificate, allows broader distribution via the built-in Get Data dialog.

References

  1. [1]
    Power Query documentation - Microsoft Learn
    Power Query is the data connectivity and data preparation technology that enables end users to seamlessly import and reshape data from within a wide range of ...Power QueryPower Query M function ...The Power Query user interfaceGetting data overviewBest practices when working ...
  2. [2]
    What is Power Query? - Power Query | Microsoft Learn
    Jan 27, 2025 · Power Query is a data transformation and data preparation engine. Power Query comes with a graphical interface for getting data from sources and a Power Query ...The Power Query user interface · Power Query template (preview) · Microsoft Teams
  3. [3]
    About Power Query in Excel - Microsoft Support
    You can use Power Query to import to a single data source, such as an Excel workbook, or to multiple databases, feeds, or services scattered across the cloud.
  4. [4]
  5. [5]
    Using the Applied Steps list - Power Query - Microsoft Learn
    Dec 5, 2024 · The Applied steps list is part of the Query settings pane in Power Query. Any transformations to your data are displayed in the Applied steps list.
  6. [6]
    Power Query in Power BI: Automate Data Transformation | CFI
    Power Query saves time on repetitive data preparation and ensures reliable results for analysis and reporting in Power BI. FAQs About Power Query in Power BI.
  7. [7]
    What is Power BI? Overview of Components and Benefits
    Jun 30, 2025 · Power BI is Microsoft's business analytics platform that helps you turn data into actionable insights.Business Users · Get started · Paginated reports
  8. [8]
    Understanding query evaluation and query folding in Power Query
    Apr 30, 2025 · This article provides a basic overview of how M queries are processed and turned into data source requests.
  9. [9]
    Using the data profiling tools - Power Query | Microsoft Learn
    Aug 28, 2025 · Column profile. This feature provides a more in-depth look at the data in a column. Apart from the column distribution chart, it contains a ...
  10. [10]
    Power BI data sources - Microsoft Learn
    Sep 30, 2025 · For a list of the connectors available in Power Query, see Connectors in Power Query. For information about dataflows in Power BI, see ...Connectors in Power Query · Power BI report data sources
  11. [11]
    Power Query as an SSIS Alternative - P3 Adaptive
    Sep 17, 2015 · This is my situation, and if this also sounds like you then Power Query is a great alternative. The benefits of Power Query over SSIS include:.Missing: comparison | Show results with:comparison
  12. [12]
    Power Query M formula language reference - Microsoft Learn
    Power Query M is used to filter, combine, and mash-up data from one or more supported data sources.
  13. [13]
    Data Points - Let Power Users Create Their Own OData Feeds
    At the SQLPass Summit in October 2011, Microsoft announced a new tool under development that's currently called Microsoft Codename “Data Explorer.” Here, I ...Missing: origins | Show results with:origins
  14. [14]
    Power Query Origins w/ Sid Jayadevan & Miguel Llopis - P3 Adaptive
    Mar 16, 2021 · They were both around and involved when Power Query essentially emerged from the primordial ooze at Microsoft. ... acquisition so that you ...
  15. [15]
    Getting started with Power Query and Power Map
    Note that Power Query was previously known as Codename “Data Explorer”. ... Microsoft Power Query for Excel · Microsoft Power Map for Excel (GeoFlow). Access ...
  16. [16]
    Microsoft Power Query for Excel
    Jul 15, 2024 · Microsoft Power Query for Excel is an Excel add-in that enhances the self-service Business Intelligence experience in Excel by simplifying data discovery.
  17. [17]
    Microsoft Flow October 2018 Update: integrations with Office 365 ...
    Power Query is a data ingestion tool that allows power users to transform, filter, manipulate, and import data into popular data stores like Power BI and CDS.
  18. [18]
    What's new in SQL Server Analysis Services
    ### Summary of Power Query or M Language Integration in SSAS 2017
  19. [19]
    Power Query template (preview) - Microsoft Learn
    Jun 14, 2024 · A Power Query template is a file that encompasses the Power Query script and its associated metadata for a single Power Query project.
  20. [20]
    Introducing Improvements to the Report Copilot in Power BI
    Oct 20, 2025 · With this update, Copilot in Power BI not only helps you create entire report pages in seconds but now also gives you more control, flexibility, ...Missing: Query | Show results with:Query
  21. [21]
    What's New? - Microsoft Fabric
    Sep 15, 2025 · Copilot in Fabric is now available to all customers, including Copilot for Power BI ... Updates to Power BI Desktop and the Power BI ...Features Currently In... · Generally Available Features · Microsoft Fabric Platform...
  22. [22]
    The Power Query user interface - Microsoft Learn
    Jan 23, 2025 · In this user interface, you can add or modify queries, manage queries by grouping or adding descriptions to query steps, or visualize your queries and their ...Using the Applied Steps list · Diagram view · Using Schema view (Preview)
  23. [23]
    Getting data overview - Power Query - Microsoft Learn
    Jul 10, 2025 · Power Query can connect to many different data sources so you can work with the data you need. This article walks you through the steps for ...
  24. [24]
    What's new in Power Query & Dataflows – November 2020
    Nov 12, 2020 · Diagram View. With Power Query customers can easily create complex dependencies between data sources, queries and data transformations. While ...
  25. [25]
    Dealing with errors - Power Query | Microsoft Learn
    Jun 20, 2025 · This article provides suggestions for how to fix the most common errors you might find at each level, and describes the error reason, error message, and error ...
  26. [26]
    M Language basic concepts - PowerQuery M - Microsoft Learn
    Aug 22, 2023 · An expression is a formula used to construct values. An expression can be formed using a variety of syntactic constructs.Missing: syntax core
  27. [27]
    Power Query M language specification - Microsoft Learn
    Nov 14, 2024 · The specification describes the values, expressions, environments and variables, identifiers, and the evaluation model that form the Power ...Missing: syntax core
  28. [28]
    Power Query M formula language introduction - Microsoft Learn
    Aug 25, 2025 · A core capability of Power Query is to filter and combine, that is, to "mash-up" data from one or more of a rich collection of supported data ...Missing: key benefits
  29. [29]
    Quick tour of the Power Query M formula language - Microsoft Learn
    Jan 27, 2025 · This quick tour describes creating Power Query M formula language queries. Note: M is a case-sensitive language.Missing: core | Show results with:core
  30. [30]
    Expressions, values, and let expression - PowerQuery M
    Aug 11, 2025 · In this article​​ A Power Query M formula language query is composed of formula expression steps that create a mashup query. A formula expression ...Structured Data Values · Record · TableMissing: core | Show results with:core
  31. [31]
  32. [32]
    Table.SelectRows - PowerQuery M - Microsoft Learn
    Sep 16, 2025 · Example 1. Select the rows in the table where the values in [CustomerID] column are greater than 2. Usage. Power Query MMissing: let Csv.
  33. [33]
    Table.Group - PowerQuery M | Microsoft Learn
    Sep 16, 2025 · Example 1. Group the table adding an aggregate column [total] which contains the sum of prices ("each List. Sum([price])").
  34. [34]
    Text.Combine - PowerQuery M | Microsoft Learn
    Sep 16, 2025 · Example 1. Combine text values "Seattle" and "WA". Usage. Power Query M Copy. Text.Combine({"Seattle", "WA"}). Output. "SeattleWA". Example 2.Syntax · About
  35. [35]
    DateTime functions - PowerQuery M - Microsoft Learn
    Nov 22, 2024 · Returns the date component of the given date, datetime, or datetimezone value. DateTime.FixedLocalNow, Returns the current date and time in the ...
  36. [36]
    Understanding Power Query M functions - PowerQuery M
    Feb 14, 2025 · In the Power Query M formula language, a function is a mapping from a set of input values to a single output value.Missing: core | Show results with:core
  37. [37]
    M Language types - PowerQuery M - Microsoft Learn
    Jan 29, 2025 · Types in the M language form a disjoint hierarchy rooted at type any , which is the type that classifies all values. Any M value conforms to ...Function Types · Nullable Types · Type Equivalence And...
  38. [38]
    Data types in Power Query - Microsoft Learn
    Mar 20, 2025 · Power Query provides a set of contextual transformations and options based on the data type of the column. For example, when you select a column ...How To Define A Column Data... · Automatic Detection Of... · Document Or Project Locale
  39. [39]
    M Language Operators - PowerQuery M | Microsoft Learn
    Feb 13, 2025 · The following table summarizes the M operators, listing the operator categories in order of precedence from highest to lowest.Missing: core | Show results with:core<|control11|><|separator|>
  40. [40]
    Power Query M type system - PowerQuery M - Microsoft Learn
    Jan 14, 2025 · The set of all M types is the union of these six sets of types: Function Types, List Types, Record Types, Table Types, Primitive Types, and Nullable Types.PRELIMINARIES · TYPES
  41. [41]
    Comments - PowerQuery M | Microsoft Learn
    Oct 9, 2022 · You can add comments to your code with single-line comments // or multi-line comments that begin with /* and end with */.
  42. [42]
    M Language lexical structure - PowerQuery M - Microsoft Learn
    Aug 9, 2022 · Describes the lexical structure of the Power Query M formula language.
  43. [43]
    Errors - PowerQuery M | Microsoft Learn
    Oct 9, 2022 · An error in Power Query M formula language is an indication that the process of evaluating an expression could not produce a value.
  44. [44]
    M Language Error Handling - PowerQuery M - Microsoft Learn
    Mar 6, 2023 · Handling errors. An error-handling-expression (informally known as a "try expression") is used to handle an error: error-handling ...
  45. [45]
    Error handling - Power Query | Microsoft Learn
    Jul 16, 2025 · This article focuses on how you can catch and manage errors based on your own specific logic. To demonstrate this concept, this article uses an ...
  46. [46]
    Diagnostics.Trace - PowerQuery M - Microsoft Learn
    Sep 16, 2025 · Diagnostics.Trace writes a trace message if tracing is enabled, and returns a value. It takes trace level, message, value, and optional delayed ...
  47. [47]
    Query diagnostics - Power Query - Microsoft Learn
    Jul 29, 2024 · Query Diagnostics helps understand Power Query's actions during authoring and refresh, tracing evaluations, and showing summarized and detailed ...Types of diagnostics · Summarized vs. detailed view
  48. [48]
    Alternatives to out-of-box connectivity in Power Query - Microsoft Learn
    Oct 1, 2025 · While Power Query offers out-of-box connectivity to over 150 data sources, there might be cases where you want to connect to a data source ...
  49. [49]
    List of all Power Query connectors - Microsoft Learn
    Sep 11, 2025 · The following table contains a list of all the connectors currently available for Power Query. For those connectors that have a reference page in this document ...
  50. [50]
    Power Query Web connector - Microsoft Learn
    Mar 24, 2025 · The Power Query Web connector loads data from websites, including web pages and files, using various authentication methods. It can be used in  ...<|separator|>
  51. [51]
    Query folding examples in Power Query - Microsoft Learn
    This article provides some example scenarios for each of the three possible outcomes for query folding. It also includes some suggestions on how to get the ...
  52. [52]
    Query folding indicators in Power Query - Power Query
    ### Summary: Monitoring Query Folding in the UI
  53. [53]
    DirectQuery in Power BI: When to Use, Limitations, Alternatives
    Sep 25, 2025 · Power Query folding is required for scalable performance. Transformations must condense into a single native query. Complex steps ...Missing: mechanism | Show results with:mechanism<|control11|><|separator|>
  54. [54]
    Use DirectQuery in Power BI Desktop - Microsoft Learn
    Oct 1, 2025 · Learn how to use DirectQuery in Power BI Desktop to connect directly to data sources without importing data, with guidance on benefits, ...Publish To The Power Bi... · Considerations And... · Other Directquery...
  55. [55]
    DirectQuery model guidance in Power BI Desktop - Microsoft Learn
    Dec 30, 2024 · This article targets data modelers developing Power BI DirectQuery models, developed by using either Power BI Desktop or the Power BI service.Optimize data source... · Optimize model design
  56. [56]
    Power BI May 2025 Feature Summary
    May 19, 2025 · In April 2025, we announced a new option to use the built-in driver to connect to Oracle database in Power BI Desktop. With the May release ...
  57. [57]
    Use composite models in Power BI Desktop - Power BI
    ### Overview of Composite Models in Power BI
  58. [58]
    Using custom functions in Power Query - Microsoft Learn
    Feb 5, 2025 · A Power Query custom function is a mapping from a set of input values to a single output value, and is created from native M functions and operators.
  59. [59]
    Using parameters - Power Query - Microsoft Learn
    Mar 24, 2025 · Custom function argument: You can create a new function from a query and reference parameters as the arguments of your custom function. The ...Missing: expression | Show results with:expression
  60. [60]
    Develop a connector using the Power Query SDK - Microsoft Learn
    Oct 1, 2025 · The Power Query SDK is a set of tools designed to help you create Power Query connectors. These connectors are often referred to as custom connectors or Power ...
  61. [61]
    Connector Extensibility in Power BI - Microsoft Learn
    Sep 25, 2025 · Custom connectors in Power BI extend connectivity so you can use data from hundreds of sources. This article covers connector extensibility ...
  62. [62]
  63. [63]
    Use custom data connectors with the on-premises data gateway
    Mar 15, 2023 · This site includes information on how to get started, and samples for Power BI and Power Query. Enable and use custom connectors. To enable ...Missing: .net<|control11|><|separator|>