We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi all,
I would like to create a 3 columns table in Power Query giving the complete combinations from 3 dimensions. E.g.:
- Agent : Bob, Cathy, Bernie (actually this list could contain 100 names)
- Year : 2021, 2022, 2023
- Week : 1 to 52
The result should give something like :
| Year | Week | Agent |
| 2021 | 1 | Bob |
| 2021 | 1 | Cathy |
| 2021 | 1 | Bernie |
| 2021 | 2 | Bob |
| 2021 | 2 | Cathy |
| 2021 | 2 | Bernie |
| 2021 | 3 | Bob |
| 2021 | 3 | Cathy |
| 2021 | 3 | Bernie |
and so on, until 2023; 52; Bernie.
Any tips?
Thanks a lot !
Solved! Go to Solution.
This is called a Cartesian product or a cross-join.
You can use this method twice for 3 dimensions:
Cross join - Power Query | Microsoft Learn
Enjoy elegance of Power Query!
let
Agents = {"Bob","Cathy","Bernie"},
Years = {2021 .. 2023},
Weeks = {1 .. 52},
#"Cartesian Product" =
List.Accumulate(
{Agents,Weeks,Years},
{{}},
(s,c) => List.TransformMany(c, each s, (x,y) => {x} & (if Value.Is(y, type list) then y else {y}))
),
#"To Table" = Table.FromRows(#"Cartesian Product",{"Yr","Wk","Agt"})
in
#"To Table"Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LearnAndPractise(Everyday) ) |
This is called a Cartesian product or a cross-join.
You can use this method twice for 3 dimensions:
Cross join - Power Query | Microsoft Learn
So easy 🙂
Thanks a lot !
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 6 | |
| 4 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 11 | |
| 10 | |
| 7 | |
| 7 | |
| 6 |