[英]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.