Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
TonyHansson
Frequent Visitor

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

 

 

 

1 ACCEPTED SOLUTION
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

 

 

View solution in original post

9 REPLIES 9
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

 

 

AlienSx
Super User
Super User

let
    Source = your_table,
    group = Table.Group(Source, {"Origin2"}, {{"Count", each {1..Table.RowCount(_)}}}),
    expand = Table.ExpandListColumn(group, "Count")
in
    expand

 

= 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

 

Excel Power Query from same workbook:

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
group = Table.Group(Source, {"Origin2"}, {{"Count", each {1..Table.RowCount(_)}}}),
expand = Table.ExpandListColumn(group, "Count")
in
expand


let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcrEwMDBQitVBYVniZMUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Origin2 = _t]),
group = Table.Group(Source, {"Origin2"}, {{"Count", each {1..Table.RowCount(_)}}}),
expand = Table.ExpandListColumn(group, "Count")
in
expand

foodd_1-1693677899641.png

 

 

foodd_0-1693677852369.png

 



Hi @foodd 

Thank you

 

I get the measage:

 

Expression.Error: We cannot convert a value of type Table to type Function.
Details:
Value=[Table]
Type=[Type]

Glad that you succeeded in determining a solution that would meet your end needs, and that @AlienSx was able to provide a working solution to your original requirements.  However, this error message had nothing to do with the Solution  @AlienSx provided that met the requirement as requested.  

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

Hi @AlienSx 

 

sapimport is the table, the power query is using

Helpful resources

Announcements
December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.