Forum Discussion

nadeemrajabali's avatar
6 years ago
Solved

Transferring a cell value to column

Hi All,  Need help please.   I have this date entry in Cloumn 3 Row 1 that I want to transfer to newly added column as report date on each row. I will then use Row 2 to be my hea I get this stoc...
  • mahoneypat's avatar
    mahoneypat
    6 years ago

    I copied your data into a query and came up with one way to do what you are looking for.  Please paste this into a blank query (open Advanced Editor and replace the text there with this M code).  If you are going to automatically combine multiple files, you could use this in your transform sample file query if you use the Combine & Edit feature of Power BI.

     

    let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hVDBasMwDP0V4dMGHSjOkpKjZzutmWNndhJWshzG6KGHrWNNYZ8/t24OHYHq8p4ePD1JfU/q918oVwLMniwIPx7G0MVGjdvPyMT28PGz+x53+y8yLHqSZ4hJ0JOUIiINbFLY2zEIy2dlQDClN+DXykjg1gigNKv0tT/HLMHuzEtWpIgpXCoodeuUb4B1ljNhHzjT0ohWszjtatASMSsmDCudTrGmcfYVuhpm6r87xwmju2Ihk1WKgVU6BGoBtZPeSzHrLia8fCGufPY6WYYPCLBuxYziM+5HGhGxKJanbGts1WoPBWpI6I3NMZ8wUmW4sy8ta+BJrqXZaGgqD3dNze/JMPwB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, #"Data snapshot as at: 02/09/19" = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Data snapshot as at: 02/09/19", type text}, {"Column3", type text}}),
    #"Demoted Headers" = Table.DemoteHeaders(#"Changed Type"),
    basetable = Table.TransformColumnTypes(#"Demoted Headers",{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}}),
    ExtractDate = Text.AfterDelimiter(basetable[Column3]{0}, "Data snapshot as at: "),
    Custom1 = basetable,
    #"Removed Top Rows" = Table.Skip(Custom1,1),
    #"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Pax FGD No", Int64.Type}, {"Cust FG No", type text}, {"Item No", type text}, {"Description", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Date", each ExtractDate),
    #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom",{{"Date", type date}})
    in
    #"Changed Type2"

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat