1

我正在尝试在表中创建一个新列,例如此处的最后一列: 在此处输入图像描述

我可以根据时间戳计算添加到购物篮中的同一类别的累积产品。我尝试分组并添加索引列,但时间戳非常重要(如第 7 行和第 8 行所示),我希望重置计数,因为它们与类别 1(Cat1)中的其他产品不连续。

谢谢你的帮助

4

1 回答 1

0

这不是一个明确的解决方案,但我希望这是一个观点:

在您的文件中对我来说似乎更重要的是,比“添加到 Baket Timestamp”列更重要的是项目购买的连续性。

因此,每次出现一个类别并替换另一个类别时,都应该创建一个新的单独索引。

我朝那个方向尝试了更多,但我还没有完整的解决方案。我真的希望以下步骤仍然有用:

  AddedIndex = Table.AddIndexColumn(#"Promoted Headers", "Index", 0, 1),
    //This adds your index
    #"Added Custom" = Table.AddColumn(AddedIndex, "Compare", each if AddedIndex{[Index]}[Product Category] <> AddedIndex{[Index]-1}[Product Category] then "category change" else "same category"),
     //This compares the row above in the "Product Category" column and the row below, in order to spot whenever we get a "change" in our sequence.
     // I get an error however for my the first row, because an "Index" cannot be negative. I do not know how to solve this issue yet.
    #"Added Conditional Column1" = Table.AddColumn(#"Added Custom", "Custom", each if [Compare] = "category change" then 0 else {[Index]+1})
in
    #"Added Conditional Column1"
     //In this last step I was aiming to either create a "local" index each time there is varaition between "same category" and "category change" or keep adding one but I encounter the following error: "we cannot appliy field acces to the type list"
于 2020-04-19T17:49:09.213 回答