简体   繁体   English

如何创建 Power Query 自定义列并将 excel 公式插入到最终表格的每个单元格中?

[英]How do i create a Power Query custom column AND insert an excel formula into each cell of the final table?

I want that when the table is created there will be a fully functioning excel formula.我希望在创建表时会有一个功能齐全的 excel 公式。 If I try with "... each "=[@[Prog.]]" there will insert only the text not the formula.如果我尝试使用 "... each "=[@[Prog.]]" 将只插入文本而不是公式。

PS: I'm new to this so, excuse me if this is basic. PS:我是新手,如果这是基本的,请原谅。

试图插入一个excel公式

From what I understand, you can create Excel formulas in Power Query and pass those to your Excel worksheet but the worksheet won't automatically recalculate . 据我了解,您可以在Power Query中创建Excel公式并将其传递给Excel工作表, 但该工作表不会自动重新计算 This earlier post addressed the same thing. 较早的帖子也谈到了同样的事情。

I tried this out by creating a table with two columns: "Column1" and "Column2", with the numbers 1 & 2 in each, respectively. 我通过创建一个包含两列的表来进行了尝试:“ Column1”和“ Column2”,分别具有数字1和2。 Then, I loaded the table into Power Query and created a new column, "Custom", with the formula, "=" & Text.From([Column1]) & "+" & Text.From([Column2]) . 然后,我将该表加载到Power Query中,并使用公式"=" & Text.From([Column1]) & "+" & Text.From([Column2])创建一个新列“ Custom”。 (To be clear, the = here is not the = that is already populated when the new column dialog box pops up, it's additional.) Anyhow, I got this table from that formula: (要清楚, = 并不是在弹出新列对话框时已经填充的= ,这是附加的。)无论如何,我从该公式中得到了这个表:

在此处输入图片说明

Then, when I clicked "Close and Load," my Excel worksheet was loaded with this: 然后,当我单击“关闭并加载”时,我的Excel工作表已加载以下内容:

在此处输入图片说明

Notice it looks just like text, but in the formula bar, it looks like this: 注意它看起来像文本,但是在编辑栏中看起来像这样:

在此处输入图片说明

Notice there isn't a ' before the = , so it's a formula. 注意=之前没有' ,所以它是一个公式。 If it were just text, it would be '=1+2 instead of =1+2 . 如果只是文本,则为'=1+2而不是=1+2

Since the cell doesn't automatically recalculate, I had to click the cell I wanted to update, and then click in the formula bar and then press enter. 由于单元格不会自动重新计算,因此我必须单击要更新的单元格,然后在编辑栏中单击,然后按Enter。 That gave me this: 那给了我这个:

在此处输入图片说明

I tried to use F9 to manually recalculate, but it did not work. 我尝试使用F9进行手动重新计算,但是它不起作用。

Also... Every time I refreshed my query, my worksheet was set back to just the text-looking formula (ie, =1+2) and I had to re-recalculate manually. 另外...每次刷新查询时,我的工作表都被设置为仅显示文本的公式(即= 1 + 2),并且我不得不手动重新计算。 That would be a real pain to have to do that for a lot of cells each time you refresh your query. 每次刷新查询时,必须对许多单元格执行此操作确实很痛苦。

@Umut K posted a VBA-based workaround to trigger refresh all in the earlier post , but I think what you are asking to do might be more trouble than you're looking for. @Umut K在较早的文章中发布了基于VBA的变通办法来触发全部刷新,但我认为您要执行的操作可能比您想要的麻烦得多。

The above answers are correct that the formulas do not automatically recalculate, even though they are in the cell correctly.上面的答案是正确的,即公式不会自动重新计算,即使它们在单元格中是正确的。 A workaround/trick that I found was to use -Find/Replace to trigger a recalculate on every cell in one step.我发现的一种解决方法/技巧是使用 -Find/Replace 一步触发对每个单元格的重新计算。 Go to one of the cells with the formula; Go 到带有公式的单元格之一; to copy the entire formula.复制整个公式。 to open the Find/Replace dialog.打开“查找/替换”对话框。 in both the Find What and Replace With boxes in the dialog.在对话框的“查找内容”和“替换为”框中。 Click on Replace All.单击全部替换。 All the cells except the one you are in will recalculate.除了您所在的单元格之外的所有单元格都将重新计算。 Then, exit the cell you are in, and it will also recalculate.然后,退出你所在的单元格,它也会重新计算。

It seems stupid, but it works.这看起来很愚蠢,但它确实有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Excel Power Query-如何基于联接创建最终表 - Excel Power Query - How to create final table based on Joins VBA Excel,如何在单元格中插入公式? - VBA Excel, how do i insert a formula into a cell? 如何在excel中创建一个公式来搜索行中的值,然后从该列中的另一个单元格中获取值? - How do I create a formula in excel that searches for a value in row, and then takes the value from another cell in that column? 如何通过Excel数据透视表中的单元格公式过滤日期? - How do I filter dates by a cell formula in an Excel pivot table? 如何使用 Power Query M 将 Excel 表列值提取到 SQL WHERE 子句中? - How do I pull Excel table column values into a SQL WHERE clause using Power Query M? 如何在 Excel 的另一个电源查询中引用另一个表和列 - How do I reference another table and column in another power query in Excel Power Query:将文本文件的自定义列公式添加到表中 - Power Query: add custom column formula for text file to table Excel Power Query - 如何在 power query 的同一个表中追加列? - Excel Power Query - How do I append columns inside the same table in power query? 如何在输入仅为一个单元格的Excel中创建多单元格数组公式? - How do I create a multi-cell array formula in Excel whose input is just one cell? 对于Excel VBA中的每个循环,我如何引用公式中的单元格地址? - With For each loop in Excel VBA how do I reference the cell address within the formula?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM