根据时间戳,我可以在其中计算添加到购物篮的同一类别的累积产品 。我曾尝试对索引列进行分组并添加索引,但时间戳确实很重要(如第7和8行所示),我希望在此处重置计数,因为它们与类别1(Cat1)中的其他产品不连续。
感谢您的帮助
答案 0 :(得分:0)
这不是一个确定的解决方案,但是我仍然希望这是一个观点:
在您的文件中,对我而言,最重要的是物品的连续性,而不是“添加到Baket时间戳记”列。
因此,每次出现类别并替换另一个类别时,都应创建一个新的单独索引。
我试图朝这个方向做更多,但我还没有完整的解决方案。我真的希望以下步骤毫无用处:
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"