# Tags
**Software** : [[Power Query]]
**Functions** used : [[Excel.CurrentWorkbook]] [[Table.Group]] [[Text.Combine]] [[List.Sum]] [[Record.FromList]] [[Record.Combine]] [[Table.ExpandRecordColumn]] [[List.Union]] [[List.Transform]] [[Record.FieldNames]]
**Date** : 25-March-2026
# Description
🚀 In this advanced Power Query tutorial, we’ll take a deep dive into nested Table.Group techniques — grouping your data first by Task ID, then by Role — all directly in the Advanced Editor using M code. You’ll learn: ○ How to perform multi-level grouping in Power Query without extra steps in the UI. ○ How to dynamically generate column names based on data. ○ How to combine text values and sum hours per role, all in one transformation. Perfect for analysts, data modelers, and Excel/Power BI pros looking to unlock next-level M code skills. 📌 Download the sample file here: [link] 📌 Official Docs for Functions Used: ○ Table.Group ○ Text.Combine ○ List.Sum 🔥 By the end, you’ll be able to create grouped summaries that the Power Query GUI can’t generate by default.
# Video Link
<iframe width="560" height="315" src="https://www.youtube.com/embed/CBnysd71e74?si=qnOQD0zS171G0MI5" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
[GITHUB File Link](https://github.com/jbotes/powerbiTutorials/blob/main/PQ_timesheets_Video.xlsx)
# M-Query
```mquery
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
Grouping = Table.Group(
Source,
// Group 1 - Task Nr
{"TaskNr"},
{"Data",
each
// Group 2 - Role
let
RoleGroup = Table.Group(
_,
{"Role"},
{"rcd",
each
let
RolePlural = [Role]{0} & "s" ,
RoleDesc = {RolePlural, RolePlural & " Hours"},
Values = {Text.Combine([Person],", "),List.Sum([Hours])}
in
Record.FromList(Values, RoleDesc)
}
)
in
Record.Combine(RoleGroup[rcd])
}
),
#"Expanded Data" =
Table.ExpandRecordColumn(
Grouping,
"Data",
List.Union(
List.Transform(
Grouping[Data],
each Record.FieldNames(_)
)
))
in
#"Expanded Data"
```
## Optional Tags
**Tags** :
**Technique** : [[Nested Let]] [[Dynamic Grouping]]