Power Query: 使用列位置添加周列

huangapple go评论64阅读模式
英文:

Power Query : Add Week column using the column position

问题

我想要添加一个新列,显示从另一个日期列获取的每周日期。

这段代码有效:

#"添加星期几" = Table.AddColumn(#"添加日期", "星期几", each Date.DayOfWeek([DATE_JOURNEE_PRODUCTION], Day.Monday))

但是,我无法用日期列的名称(称为DATE_JOURNEE_PRODUCTION)来替代该列在表中的位置。

我尝试替换代码为:

#"添加星期几" = Table.AddColumn(#"添加日期", "星期几", each Date.DayOfWeek(Table.ColumnNames(#"扩展的数据"){1}, Day.Monday))

但这里的Table列名不起作用。

有人可以帮助我吗?

谢谢!

英文:

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

答案1

得分: 0

尝试

每个 Date.DayOfWeek(Record.Field(_, Table.ColumnNames("Expanded Data"){1}), Day.Monday)
英文:

try

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

huangapple
  • 本文由 发表于 2023年3月3日 23:45:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/75629164.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定