Forum Discussion

Shan_Drex12's avatar
Shan_Drex12
Helper I
5 years ago
Solved

2 column merge dynamic

Hi All,   Quick question: I have a data sheet that only has this column Code alongwith some other data (Sheet 1. Full Data) Code AR BA BG BH BO BT CP CR...
  • smpa01's avatar
    5 years ago

    Shan_Drex12 

    can you please try this as a custom column. I have removed the last column from the lookuptable to test out the code.

    //table t2
    let
        Source = Web.BrowserContents("https://community.powerbi.com/t5/Power-Query/2-column-merge-dynamic/m-p/1645518#M50293"),
        #"Extracted Table From Html" = Html.Table(Source, {{"Column1", "TABLE:nth-child(8) > * > TR > :nth-child(1)"}, {"Column2", "TABLE:nth-child(8) > * > TR > :nth-child(2)"}}, [RowSelector="TABLE:nth-child(8) > * > TR"]),
        #"Changed Type" = Table.TransformColumnTypes(#"Extracted Table From Html",{{"Column1", type text}, {"Column2", type text}}),
        #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
        #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Code", type text}, {"Names", type text}}),
        #"Removed Bottom Rows" = Table.RemoveLastN(#"Changed Type1",1)
    in
        #"Removed Bottom Rows"
    //table t1
    let
        Source = Web.BrowserContents("https://community.powerbi.com/t5/Power-Query/2-column-merge-dynamic/m-p/1645518#M50293"),
        #"Extracted Table From Html" = Html.Table(Source, {{"Column1", "TABLE:nth-child(4) > * > TR > :nth-child(1)"}}, [RowSelector="TABLE:nth-child(4) > * > TR"]),
        #"Changed Type" = Table.TransformColumnTypes(#"Extracted Table From Html",{{"Column1", type text}}),
        #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
        #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Code", type text}}),
        #"Added Custom1" = Table.AddColumn(#"Changed Type1", "Custom.1", each let x = Text.From([Code]),
    y = List.PositionOf(t2[Code],x),
    z = try t2[Names]{y} otherwise null in z)
    in
        #"Added Custom1"