Power Query使用Excel范围中的变量列名相乘

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

Power Query multiply column using variable column name from excel range

问题

我有问题涉及Power Query中的一行代码:我想要添加一个新列,将我的表格中的一个现有列乘以2。
对我来说,这里的难点是,我将要乘以2的列是由同一Excel工作表中的单元格值定义的。

我的问题是:如何添加一个新列,知道现有列的引用是由一个单元格值给出的?

我尝试了类似这样的代码,但不起作用:

#“添加FAT” = Table.AddColumn(#“添加YEAR”, “FAT (g/100 g)”, each Excel.CurrentWorkbook(){[Name=“Fat_variable”]}[Content][Colonne1]{0}*2)

谢谢大家!

英文:

I'm having problems with a code line in Power Query : I want to add a new column multiplying by 2 one existing column of my table.
The difficulty for me here is that the column that I will multiply by 2 will be defined by a cell value contained in the same Excel worksheet.

My question is : how can I add a new column knowing that the reference of the existing column is given by a cell value?

I'm trying something like this, but not working :

#"Add FAT" = Table.AddColumn(#"Add YEAR", "FAT (g/100 g)", each Excel.CurrentWorkbook(){[Name="Fat_variable"]}[Content][Colonne1]{0}*2)

Thank you all !!

答案1

得分: 2

尝试

#"添加脂肪" = Table.AddColumn(#"添加年份", "脂肪 (g/100 g)", each Record.Field(_,Excel.CurrentWorkbook(){[Name="Fat_variable"]}[Content]{0}[Column1])*2)
英文:

try

#"Add FAT" = Table.AddColumn(#"Add YEAR", "FAT (g/100 g)", each Record.Field(_,Excel.CurrentWorkbook(){[Name="Fat_variable"]}[Content]{0}[Column1])*2)

where Fat_variable is a defined single cell range that contains a Column name

Power Query使用Excel范围中的变量列名相乘

huangapple
  • 本文由 发表于 2023年4月19日 18:14:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76053309.html
匿名

发表评论

匿名网友

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

确定