Power Query Table.FillDown with condition

有没有办法根据条件填满表格?

下面我的表格样本。 我想根据合同列填写date列。 例如,如果合同不以GB开头,则填写上一行的date,否则留空。

Contract Date Role 01F001 3/7/2016 A 01F017 5/6/2016 A GB0007 B GB0007 B LBCA09 2/29/2016 A LBCA09 B LBCA09 B LBCA09 B LBCA12 2/25/2016 A LBCA12 B 

这是我想要的最终数据

 Contract Date Role 01F001 3/7/2016 A 01F017 5/6/2016 A GB0007 B GB0007 B LBCA09 2/29/2016 A LBCA09 2/29/2016 B LBCA09 2/29/2016 B LBCA09 2/29/2016 B LBCA12 2/25/2016 A LBCA12 2/25/2016 B 

我试图添加一个if语句之外的Table.Filldown函数,但得到一个语法错误。

 = if not Text.StartsWith([Contract],"GB") then Table.FillDown(#"Replaced Value",{"Date"}) 

任何帮助表示赞赏!

您可以通过多个步骤完成此操作。

  • 填写“date”栏
  • 添加条件列不以“GB”开头,并从“date”
  • 删除“date”列
  • 将“自定义”列重命名为“date”

你可以使用Table.Partition。 这种修改适用于更复杂的情况。

 MyFunc = (_) => if Text.StartsWith(_, "GB") then 1 else 0, Partitioned = Table.Partition(YourTable, "Contract", 2, each MyFunc(_)), DownFilled = Table.FillDown(Partitioned{0}, {"Date"}), Result = Table.Combine({DownFilled, Partitioned{1}})