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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
KervBruce
Advocate I
Advocate I

Multiply two tables

The title of my question isn't clear but I didn't know what to call it.

I have a table of project, with 2 columns: ID and Title.

I have another table of reporting periods (months) from 2021 to today.

I want to create a table with a row for each project for each period.

So with 165 projects and 38 perios I expect 6270 rows.

Can you suggest the M Code to achieve this?

2 ACCEPTED SOLUTIONS
ronrsnfld
Super User
Super User

  • Add a custom column with a List of the Reporting Periods
  • Expand that column to new rows.

Code might be something like:

 

 

   #"Added Custom" = Table.AddColumn(#"Previous Step", "Reporting Period", each #"Reporting Periods", type {text}),
    #"Expanded Reporting Period" = Table.ExpandListColumn(#"Added Custom", "Reporting Period")

 

 

If your List of Reporting periods is in a table named Reporting Periods, you might need to change the reference to a table column type reference, eg   #"Reporting Periods"[Column Name]

 

View solution in original post

Hello @KervBruce,

you only need to add two lines of code:

 

let
    Source = YourProjectTable,
    ColumnMonth = Table.AddColumn(Source, "Month", each YourDatesTable),
    OpenColumnMonth = Table.ExpandTableColumn(ColumnMonth, "Month", {"Month"}, {"Month"})
in
    OpenColumnMonth

 

 Best regards from Germany

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
ronrsnfld
Super User
Super User

  • Add a custom column with a List of the Reporting Periods
  • Expand that column to new rows.

Code might be something like:

 

 

   #"Added Custom" = Table.AddColumn(#"Previous Step", "Reporting Period", each #"Reporting Periods", type {text}),
    #"Expanded Reporting Period" = Table.ExpandListColumn(#"Added Custom", "Reporting Period")

 

 

If your List of Reporting periods is in a table named Reporting Periods, you might need to change the reference to a table column type reference, eg   #"Reporting Periods"[Column Name]

 

Thank you @ronrsnfld That was very simple 🙂

Hello @KervBruce,

you only need to add two lines of code:

 

let
    Source = YourProjectTable,
    ColumnMonth = Table.AddColumn(Source, "Month", each YourDatesTable),
    OpenColumnMonth = Table.ExpandTableColumn(ColumnMonth, "Month", {"Month"}, {"Month"})
in
    OpenColumnMonth

 

 Best regards from Germany

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 @ManuelBolz 

That's excelent, thank you

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors