簡體   English   中英

如何在 Power BI 中為累積計數創建列?

[英]How can I create a column for cumulative count in Power BI?

我正在嘗試在表中創建一個新列,例如此處的最后一列: 在此處輸入圖像描述

我可以根據時間戳計算添加到購物籃中的同一類別的累積產品。 我嘗試分組並添加索引列,但時間戳非常重要(如第 7 行和第 8 行所示),我希望重置計數,因為它們與類別 1(Cat1)中的其他產品不連續。

謝謝你的幫助

這不是一個明確的解決方案,但我希望這是一個觀點:

在您的文件中對我來說似乎更重要的是,比“添加到 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"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM