Forum Discussion

TonyHansson's avatar
TonyHansson
Frequent Visitor
2 years ago
Solved

Count calculated columns

I have table.

 

Origin2

D8000

D8000

D9000

D9000

D9000

 

I want add a column making a calculated count.

 

Origin2    Count

D8000         1

D8000         2

D9000         1

D9000         2

D9000         3

 

How can I do this ?

 

Regards Tony

 

 

 

  • Hi

     

    Found this youtube:

     

    = Table.AddColumn(BufferedTable, "RunningCount", (OT) => Table.RowCount( Table.SelectRows(BufferedTable, (IT) => IT[Transaction No] <= OT[Transaction No] and IT[Origin2] = OT[Origin2])))

     

    Thank you for help

     

     

9 Replies

  • let
        Source = your_table,
        group = Table.Group(Source, {"Origin2"}, {{"Count", each {1..Table.RowCount(_)}}}),
        expand = Table.ExpandListColumn(group, "Count")
    in
        expand
    • TonyHansson's avatar
      TonyHansson
      Frequent Visitor

       

      = Table.AddColumn(#"Removed Columns4", "Custom",  let source = SAPIMPORT,
      group = Table.Group(source, {"Origin2"}, {{"Count",each {1..Table.RowCount(_)}}}),
      expand = Table.ExpandListColumn(group, "Count")
      in expand)

       

      Expression.Error: The column 'Origin2' of the table wasn't found.
      Details:
      Origin2

       

      Origin2 is not a part of the table "SAPimport" but created later

       

      Tony

       

      • AlienSx's avatar
        AlienSx
        Super User

        You have a single column table in your original message. What is SAPimport? We are not aware of this. 

  • TonyHansson's avatar
    TonyHansson
    Frequent Visitor

    Hi

     

    Found this youtube:

     

    = Table.AddColumn(BufferedTable, "RunningCount", (OT) => Table.RowCount( Table.SelectRows(BufferedTable, (IT) => IT[Transaction No] <= OT[Transaction No] and IT[Origin2] = OT[Origin2])))

     

    Thank you for help