Forum Discussion

Mederic's avatar
Mederic
Post Patron
2 years ago
Solved

Fill a column with identical labels

Hello everyone, I have a column with a number of nested data that repeat every 5 values How do I get a column with label names? (see screenshot) Thanks in advance Best Regards   Input James M ...
  • ronrsnfld's avatar
    2 years ago

    Here's one way:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8krMTS1WitWJVvIFk45GhsZghqGlvoGpvqGlpQmY65Ofl5KfB1GYWJSZCGa5gUknMyOIFiMLfQMzoBZziJYAoDqI0Y55JRn5eZXI1lgaG0L0GOobWAL1WECMcEotyskEWhMLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Input = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Input", type text}}),
    
        Labels = {"Name","Gender","ID","Birth","City"},
        #"Label Column" = List.Repeat(Labels,Table.RowCount(#"Changed Type")/5),
    
        #"Add Label Column" = Table.FromColumns(
            Table.ToColumns(#"Changed Type") & 
            {#"Label Column"}, Table.ColumnNames(#"Changed Type") & {"Result"}),
    
        #"Changed Type1" = Table.TransformColumnTypes(#"Add Label Column",{{"Result", type text}})
    in
        #"Changed Type1"