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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
IvanFradinger
Regular Visitor

Creating a new Table where all product codes have their own date lines

Hello, im having some issues with these 2 tables: im trying to merge these 2 tables in power query. The following have the structure:

 

Table 1: has 14 lines

 

Code

A00698919717702

A00498968207604

A00098917007702

A00098917007604

A0079893971

A00798916717706

A00798916717604

A00998920717704

A00998920717604

A0019869071

A00998976717604

A0009866770

A00198605707706

A00098906067501

 

Table 2: has 730 lines

 

Date      Month   Week    Gross     Losses   Net

1/1/22  1             52          0             0             0

1/2/22  1             52          0             0             0

1/3/22  1             1             0             0             0

1/4/22  1             1             0             0             0

1/5/22  1             1             0             0             0

1/6/22  1             1             0             0             0

1/7/22  1             1             0             0             0

1/8/22  1             1             0             0             0

1/9/22  1             1             0             0             0

1/10/22               1             2             0             0             0

1/11/22               1             2             0             0             0

1/12/22               1             2             0             0             0

1/13/22               1             2             0             0             0

....

 

Im essentialy trying to merge both tables; the result would be table 2 with (14x730 = 10220 lines) and the original columns, with one additional column that shows each specific date for each product of table 1. 

 

Date    Month Week  Gross  Losses Net      Code

1/1/22 1          52        0          0          0          A00698919717702

1/2/22 1          52        0          0          0          A00698919717702

1/3/22 1          1          0          0          0          A00698919717702

1/4/22 1          1          0          0          0          A00698919717702

1/5/22 1          1          0          0          0          A00698919717702

1/6/22 1          1          0          0          0          A00698919717702

1/7/22 1          1          0          0          0          A00698919717702

1/8/22 1          1          0          0          0          A00698919717702

1/9/22 1          1          0          0          0          A00698919717702

1/10/22           1          2          0          0          0          A00698919717702

1/11/22           1          2          0          0          0          A00698919717702

1/12/22           1          2          0          0          0          A00698919717702

1/13/22           1          2          0          0          0          A00698919717702

 

Thank you very much,

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

In the Table 2 you can add custom column = "#Table 1", something like this:

let
    Source = #"Table 2",
    #"Added Custom" = Table.AddColumn(Source, "Custom", each #"Table 1")
in
    #"Added Custom"

and then expand the result



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

2 REPLIES 2
wdx223_Daniel
Super User
Super User

NewStep=#table(Table.ColumnNames(Table2)&{"Code"},List.TransformMany(Table.ToRows(Table2),each Table1[Code],(x,y)=>x&{y}))

Stachu
Community Champion
Community Champion

In the Table 2 you can add custom column = "#Table 1", something like this:

let
    Source = #"Table 2",
    #"Added Custom" = Table.AddColumn(Source, "Custom", each #"Table 1")
in
    #"Added Custom"

and then expand the result



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors