强大的查询-复杂的自定义列

时间:2019-07-03 14:36:01

标签: excel if-statement powerquery m customcolumn

我需要创建一个自定义列,该列查找a的1列,并基于a,从b修剪一个值并将该值放入c

B部分:现在,如果a中的值不符合我的条件,那么它将查看d列以查找它是否与上一行相同,如果是,则将其放入c从上一行到新行。

我现在有一部分:

if Text.End ([SAP segment name],3) = "K09"
then Text.Trim (Text.Start([Application data],35)) else ""

我需要B部分的帮助

1 个答案:

答案 0 :(得分:0)

您的公式[B3 = IF(RIGHT(R3,3)=“ K09”,TRIM(LEFT(W3,35)),B2)]将为每一行返回错误,直到R第一次在K09中结束。但是,如果那是您想要的,那么

let Source = Table.FromList({
[SAP segment name="L04K29", Application data ="ABCDEFGHIJKLMNOP12345VWXYZabcdefghijklmnopqrstuvwxyz"] ,  
[SAP segment name="R03L09", Application data ="abcdefghijklmnop67890qrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"] ,  
[SAP segment name="L04K09", Application data ="ABCDEFGHIJKLMNOP987654QRSTUVWXYZabcdefghijklmnopqrstuvwxyz"] ,  
[SAP segment name="L04K09", Application data ="ABCDEFGHIJKLMNOPQR321254STUVWXYZabcdefghijklmnopqrstuvwxyz"] ,  
[SAP segment name="R03G09", Application data ="abcdefghijklmnopqrst87562uvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"] ,  
[SAP segment name="L04K09", Application data ="ABCDEFGHIJKLMNOPQRSTU45265VWXYZabcdefghijklmnopqrstuvwxyz"] 
}, Record.FieldValues, {"SAP segment name", "Application data"}),
#"Added Custom" = Table.AddColumn(Source, "Custom", each if Text.End ([SAP segment name],3) = "K09" then Text.Trim(Text.Start([Application data],35)) else null),
#"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"})
in
#"Filled Down"