Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
SMaz
Frequent Visitor

Create a custom table from 3 dimensions

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 :

YearWeekAgent
20211Bob
20211Cathy
20211Bernie
20212Bob
20212Cathy
20212Bernie
20213Bob
20213Cathy
20213Bernie

 

and so on, until 2023; 52; Bernie.

 

Any tips?

Thanks a lot !

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

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

View solution in original post

3 REPLIES 3
ThxAlot
Super User
Super User

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"

ThxAlot_0-1695243962044.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



AlexisOlson
Super User
Super User

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 !

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.