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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ebuchholz
Frequent Visitor

Running count of occurrence of value, sorted by another column

Is there a way I can get a running count based on a reoccuring value in a column, and start a new running count based on new values? Please see the example below for what I am trying to achieve. When defining where to start counting, the data would most likely be sorted by a date column. Thank you!

 

IDDesired Output
A1
A2
A3
A4
A5
B1
B2
B3
B4
C1
C2
C3
D1
D2
D3
D4
E1
E2
E3
E4
E5
C4
A6
A7
1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI,

If you can add an extra column which is the row number, i.e. 1,2,3,4,5,6... then the following logic should work:

 

Calculate(COUNTA(Table[ID]), FILTER(Table, Table[ID] = EARLIER(Table[ID]) && Table[Row Number] <= EARLIER(Table[Row Number])))

 

Essentially, if you are on row 1, A then this will filter your table to just be A's and then any row less than or equal to the current row number and then it will count the number of A's in this filtered table.

 

So A row 3 will filter the table to just A's and then all rows less than or equal to 3.

 

Hope this helps,

 

Will

View solution in original post

1 REPLY 1
Anonymous
Not applicable

HI,

If you can add an extra column which is the row number, i.e. 1,2,3,4,5,6... then the following logic should work:

 

Calculate(COUNTA(Table[ID]), FILTER(Table, Table[ID] = EARLIER(Table[ID]) && Table[Row Number] <= EARLIER(Table[Row Number])))

 

Essentially, if you are on row 1, A then this will filter your table to just be A's and then any row less than or equal to the current row number and then it will count the number of A's in this filtered table.

 

So A row 3 will filter the table to just A's and then all rows less than or equal to 3.

 

Hope this helps,

 

Will

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.