Search code examples
positionpowerquerycalculated-columns

Power Query : Add Week column using the column position


I want to add a new column with the day of the week, from another date column.

This code works :

#"Add DAY OF WEEK" = Table.AddColumn(#"Add DAY", "WEEK DAY", each Date.DayOfWeek([DATE_JOURNEE_PRODUCTION], Day.Monday))

But I cannot replace the name of the date column (called DATE_JOURNEE_PRODUCTION) by the position of this column in the table.

I'm trying to replace the code for something like

#"Add DAY OF WEEK" = Table.AddColumn(#"Add DAY", "WEEK DAY", each Date.DayOfWeek(Table.ColumnNames(#"Expanded Data"){1}, Day.Monday))

But this Table column names is not working.

Anybody could help me ?

Thank you !

Create a new column using the position of another colum


Solution

  • try

    each Date.DayOfWeek(Record.Field(_,Table.ColumnNames(#"Expanded Data"){1}), Day.Monday)