Forum Discussion

Idreeesi's avatar
Idreeesi
Copper Contributor
Feb 13, 2022
Solved

Custom Column with a particular cell's value (Power Query)

Hi  This should be simple for many people (but not for a newbie like me!). I need to create a new column that contains the value of the top-left cell ("Progress for week 02" in this case).  C...
  • Lorenzo's avatar
    Lorenzo
    Feb 15, 2022

    Hi Idreeesi 

    Re. I need to promote Row # 2 (the one that contains 'Stages') as a header. However, my newly created column ('Custom') gets the title of "week 02" which make it not dynamic (and creates errors on the next steps). I wonder if there is a method whereby I could promote all other rows columns as a header except 'Custom'

     

    One way:

        MyTableBeforePromoting = ...,
        CurrentNames = List.Skip( Table.ColumnNames(MyTableBeforePromoting) ),
        NewNames = List.Skip( Record.ToList( Table.First( Table.Skip(MyTableBeforePromoting) ) ) ),
        RemovedTopRows = Table.Skip(MyTableBeforePromoting, 2),
        RenamedColumns = Table.RenameColumns(RemovedTopRows,
            List.Zip({CurrentNames, NewNames})
        )

    This assumes column [Custom] is the 1st column of table, as shown in your picture

     

Resources