[英]Adding a value to an existing column in Power Query Excel
如何使用此逻辑将值“UTU”添加到当前列“仓库列表”:如果仓库列表列中有值“UTU”,则将其显示在仓库列表中,但如果没有“UTU” " 在 Depot 列表中,然后仍然显示值为零的 "UTU"。
I am using power query to connect to the data source and append query to append the multiple queries together, then I connect the pivot table in Excel to the Append query to build the report. 我该怎么做 go 关于这个,我试过条件列但没有成功。
当前 Output:
所需的 Output:
您只需要在 M 代码的末尾添加一个条件子句。
这必须在高级编辑器中完成,并且您需要扩展我显示的添加记录以涵盖您的所有列。
M代码
let
Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{
{"Depot", type text}, {"Report 1", Int64.Type}, {"Report 2", Int64.Type}}),
//if number of columns is stable, this will work OK
//if the number of columns might vary, or be named differently, we will have to make some changes
utuRow = if List.Contains(#"Changed Type"[Depot],"UTU")
then #"Changed Type"
else Table.InsertRows(#"Changed Type",
Table.RowCount(#"Changed Type"),
{[Depot="UTU",Report 1=0,Report 2=0]})
in
utuRow
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.