Power Query: Optimizing Group Uniques
Power BI
Nov 5, 2023 11:45 AM

Power Query: Optimizing Group Uniques

by HubSite 365 about Wyn Hopkins [MVP]

Microsoft MVP | Author | Speaker | Power BI & Excel Developer & Instructor | Power Query & XLOOKUP | Purpose: Making life easier for people & improving the quality of information for decision makers

Data AnalyticsPower BILearning Selection

Boost your Microsoft expertise with this Power Query challenge, a comprehensive deep dive into data extraction and transformation.

The video, authored by Wyn Hopkins (MVP), puts forth a challenge that revolves around the concept of unifying multiple records into single rows using Power Query. The challenge, along with its solutions, is the highlight of this video.

  • 00:00 Intro
  • 00:19 The Challenge
  • 01:44 The Long Solution
  • 05:44 The Better Solution

The Role of Power Query

Power Query, a creation by Microsoft, is a highly effective ETL Tool for data extraction, transformation, and loading. It allows retrieval of data from various sources, processes it, and then transfers it into one or multiple target systems. It has a wide range of applications in the Microsoft Power Platform and used extensively for business intelligence on fully and partially self-service platforms, such as Excel, Power BI, Analysis Services, Power Apps, etc.

The transformation aspect of ETL is connected to data modeling, and in cases where the data lacks a model or needs further development, Power Query is the tool to rely on.

Tracking the Growth of Power Query

The video hints at the historical development of Power Query, which was initially an extra feature in Power Pivot, integral for creating pivot tables in Excel 2010 and 2013. The tool underwent a temporary name change to Get & Transform in Excel 2016 but soon reverted to the popular name of Power Query.

The video also mentions how Power Query revolves around the mashed language called M, which is used to combine data queries. The majority of user interaction can be done through a GUI, but advanced users have the option to use the advanced editing mode where developers can write in the M formula language.

Using DirectQuery and Query Folding

Using DirectQuery in Power BI has limited usage of M code as compared to when using Import. For complicated queries, users may need to work directly with the M language without requiring any user interfacing.

Query Folding bridles the potential of Power Query into a unified query at the data source. This function works like traditional ETL processes, letting users work on the data even before loading it. However, the support for Query Folding is sketchy at best, and the nature of the query folding will dangerously depend on the order of queries.

Additional Information

Additional terminologies associated with the video topic include:

  • Online analytical processing (OLAP)
  • Data Analysis Expressions (DAX) used to query models and create advanced measures.
  • Data versai


General Information about Power Query

Power Query is a Microsoft data connectivity and data preparation technology that enables business users to seamlessly access data stored in hundreds of data sources and reshape it to fit their needs, providing them with an intuitive and straightforward way to manipulate data. These capabilities go beyond traditional ETL, as they enable handling of enormous volume of data and integrate it from varying sources.

Power BI - Power Query Challenge: Optimizing Group Uniques

Learn about Group Uniques - Power Query Challenge


Exploring the realm of data processing and management, our focus today is a deep dive into Power Query tool, a key component of Microsoft's data-driven applications. Created by Microsoft, this amazing data extract, load and transformation (ETL) tool, is popularly employed to obtain data from various sources, process it and feed them into different target systems. Michrosoft has also integrated Power Query into the Microsoft Power platform.

Used in tandem with power analytics tools like Power BI, Analysis Services, Power Apps, Azure Data Factory, and Dynamics 365; this potent tool finds its place in multiple cloud services like Microsoft Dataflows subset of Power BI's cloud service or the more adaptable version of Microsoft Dataflow compatible with Power Automate. It is also found in other key applications such as Excel and SSIS.

This powerhouse ETL tool is widely used for building business intelligence in fully or semi-autonomous service platforms. It is also crucial in developing a logical data model where the pre-existing data lacks one, or when more intricate development of the data model is required. Power Query’s capabilities extend well beyond rudimentary extract, load, and transform tasks.

The roots of the Power Query lie in Power Pivot - a feature used for making pivot tables in Excel 2010 and 2013. For a brief period, in Excel 2016, it was renamed as 'Get & Transform', however, the original name, 'Power Query' was reinstated soon after.

Power Query utilizes a query language named M, short for Mashup, intended for mixing together data. Echoing similarities to F Sharp programming language, M is primarily a 'mostly pure, higher-order, dynamically typed, partially lazy, functional language.' It is vital to note that M is case-sensitive and provides a robust framework for executing complex queries.

Although much of Power Query interaction is conducted via graphical interfaces to perform basic tasks, its advanced editing mode allows developers to write in M. This not only provides more expressive power but also offers additional prospects and gives developers more control over the code generated by the graphical wizards.

  • In the M language, Power Query is written in a let expression where data and expressions reference each other and an in expression which contains the output
  • Lines in the let expression, also called steps, end with a comma with the exception of the last line
  • It supports both inline and block comments, written in C-style

One pivotal feature of Power Query in a Business Intelligence tool, such as Power BI, is the limited use of M-code in DirectQuery in contrast to Import, which has all capabilities. This is primarily due to the need for M-code in DirectQuery to be translated into SQL in real-time.

Another important feature to note is Query Folding. Essentially, this capability allows a Power Query to be converted into a single query at the data source. Query Folding imitates a traditional ETL process and permits manipulation of data before loading. However, it is worth noting that Query Folding is not always supported and the folding capacity of a query can be indicated by folding indicators like Folding, Not Folding, Might fold, opaque, and unknown. Non-folding queries need to be performed client-side and the order of the queries determines which steps get folded.

In conclusion, Power Query is a comprehensive tool for managing and transforming data, which powers a wide range of Microsoft's data analytics and processing applications.


More links on about Group Uniques - Power Query Challenge

Power Query Challenge – A Unique Problem
Oct 4, 2023 — In this month's challenge, you need to combine any non duplicate items into a single cell for each client ID#.
Using Power Query Group By In A Data Challenge
Feb 15, 2023 — In this Power Query group by Excel BI challenge, we'll examine a unique and intriguing alphabet-to-columns Excel Power BI Challenge.


Group Uniques, Power Query Challenge, Power Query, Data Analysis, Excel Power Query, Power Query Tips, Database Query, Unique Entries Query, Advanced Power Query, Data Consolidation Power Query