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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AshleyJ17
Frequent Visitor

How to progressively count values in a column

Hi All

 

After some help with the sample data i have below, i have a column called Reference and want to add a new column which counts how many occurences cumulatively within the data, for example '1472321-2860846' shows up 3 times in the reference column so what i would like is for Power Bi to show that it occurs 3 times but show the 1st instance, 2nd Instance and 3rd Instance if that makes sense, have done a bit of googling and searching this forum but so far havent found a solution 

 

Hoping this communintiy can help

 

Thanks in advanced


Ash


AshleyJ17_0-1683804172745.png

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @AshleyJ17 

try to

1) add an index column and make it like:

FreemanZ_2-1683810829256.png

https://learn.microsoft.com/en-us/power-query/add-index-column

2) add a calculated column like:

CumCount = 
COUNTROWS(
    FILTER(
        data,
        data[Reference]=EARLIER(data[Reference])
            &&data[Index]<=EARLIER(data[Index])
    )
)

it worked like:

FreemanZ_1-1683810810613.png

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @AshleyJ17 

try to

1) add an index column and make it like:

FreemanZ_2-1683810829256.png

https://learn.microsoft.com/en-us/power-query/add-index-column

2) add a calculated column like:

CumCount = 
COUNTROWS(
    FILTER(
        data,
        data[Reference]=EARLIER(data[Reference])
            &&data[Index]<=EARLIER(data[Index])
    )
)

it worked like:

FreemanZ_1-1683810810613.png

That worked like a charm thank you FreemanZ 🙂

If you have the time would you be able to explain how this works, im not too familiar with the EARLIER function and would like to get some more understanding on the functions in the formula

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

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.