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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
BobPanna
New Member

Copying info from one table to another

I have two tables.

One contains the data separated by a line, and the other by column
For example:

BobPanna_0-1655737274171.png
BobPanna_1-1655737284351.png

 


How can I get the Total Employer data from the First table and put it in the Second Table in the Related Field?

The result would be this. I am not able to perform.

BobPanna_0-1655737363800.png

 

 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @BobPanna ;

You could merge it in power query.

1.Merge it.

vyalanwumsft_0-1655965999115.png

2.expand year and employer total.

3.add new column

vyalanwumsft_1-1655966050106.png

4.pivot column.

 

The final show:

vyalanwumsft_3-1655966159624.png

 

M language.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNlHSUTIyMLQAU0ZGQMovtVzBvyC1KLEkMz8PyHfOzyvJzCtNLSaSjY5idaKVTM3MITYYWkIsMgRZpO9IinU5+cWpKdjMjwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Index 2" = _t, #"lnicia lYe<" = _t, #"Last Year" = _t, #"2018 Status" = _t, #"2019 Status" = _t, #"2020 Status" = _t, #"2021Status" = _t, #"2022 Status" = _t, #"2018 Employers Total" = _t, #"2019 Employers Total" = _t, #"(blank)" = _t, #"2020 Employers Total" = _t, #"2021Employers Total" = _t, #"2022 Employers Total" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Index 2", Int64.Type}, {"lnicia lYe<", Int64.Type}, {"Last Year", Int64.Type}, {"2018 Status", type text}, {"2019 Status", type text}, {"2020 Status", type text}, {"2021Status", type text}, {"2022 Status", type text}, {"2018 Employers Total", type text}, {"2019 Employers Total", type text}, {"(blank)", type text}, {"2020 Employers Total", type text}, {"2021Employers Total", type text}, {"2022 Employers Total", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"lnicia lYe<", "lnicia Year"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"2018 Employers Total", "2019 Employers Total", "(blank)", "2020 Employers Total", "2021Employers Total", "2022 Employers Total"}),
    #"Merged Queries" = Table.NestedJoin(#"Removed Columns", {"Index 2"}, Table, {"Index2"}, "Table", JoinKind.LeftOuter),
    #"Expanded Table" = Table.ExpandTableColumn(#"Merged Queries", "Table", {"Employers Total", "Year"}, {"Table.Employers Total", "Table.Year"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Table", "Custom", each Number.ToText( [Table.Year])&" Employers Total"),
    #"Removed Columns1" = Table.RemoveColumns(#"Added Custom",{"Table.Year"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns1", List.Distinct(#"Removed Columns1"[Custom]), "Custom", "Table.Employers Total", List.Sum),
    #"Replaced Value" = Table.ReplaceValue(#"Pivoted Column",null,0,Replacer.ReplaceValue,{"2018 Employers Total", "2019 Employers Total", "2020 Employers Total", "2021 Employers Total", "2022 Employers Total"})
in
    #"Replaced Value"


Best Regards,
Community Support Team _ Yalan Wu
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

1 REPLY 1
v-yalanwu-msft
Community Support
Community Support

Hi, @BobPanna ;

You could merge it in power query.

1.Merge it.

vyalanwumsft_0-1655965999115.png

2.expand year and employer total.

3.add new column

vyalanwumsft_1-1655966050106.png

4.pivot column.

 

The final show:

vyalanwumsft_3-1655966159624.png

 

M language.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNlHSUTIyMLQAU0ZGQMovtVzBvyC1KLEkMz8PyHfOzyvJzCtNLSaSjY5idaKVTM3MITYYWkIsMgRZpO9IinU5+cWpKdjMjwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Index 2" = _t, #"lnicia lYe<" = _t, #"Last Year" = _t, #"2018 Status" = _t, #"2019 Status" = _t, #"2020 Status" = _t, #"2021Status" = _t, #"2022 Status" = _t, #"2018 Employers Total" = _t, #"2019 Employers Total" = _t, #"(blank)" = _t, #"2020 Employers Total" = _t, #"2021Employers Total" = _t, #"2022 Employers Total" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Index 2", Int64.Type}, {"lnicia lYe<", Int64.Type}, {"Last Year", Int64.Type}, {"2018 Status", type text}, {"2019 Status", type text}, {"2020 Status", type text}, {"2021Status", type text}, {"2022 Status", type text}, {"2018 Employers Total", type text}, {"2019 Employers Total", type text}, {"(blank)", type text}, {"2020 Employers Total", type text}, {"2021Employers Total", type text}, {"2022 Employers Total", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"lnicia lYe<", "lnicia Year"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"2018 Employers Total", "2019 Employers Total", "(blank)", "2020 Employers Total", "2021Employers Total", "2022 Employers Total"}),
    #"Merged Queries" = Table.NestedJoin(#"Removed Columns", {"Index 2"}, Table, {"Index2"}, "Table", JoinKind.LeftOuter),
    #"Expanded Table" = Table.ExpandTableColumn(#"Merged Queries", "Table", {"Employers Total", "Year"}, {"Table.Employers Total", "Table.Year"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Table", "Custom", each Number.ToText( [Table.Year])&" Employers Total"),
    #"Removed Columns1" = Table.RemoveColumns(#"Added Custom",{"Table.Year"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns1", List.Distinct(#"Removed Columns1"[Custom]), "Custom", "Table.Employers Total", List.Sum),
    #"Replaced Value" = Table.ReplaceValue(#"Pivoted Column",null,0,Replacer.ReplaceValue,{"2018 Employers Total", "2019 Employers Total", "2020 Employers Total", "2021 Employers Total", "2022 Employers Total"})
in
    #"Replaced Value"


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.