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
jonclay
Helper IV
Helper IV

Adding a sequential number based on the date

Hi everyone
I'm having a problem adding a sequential number column to my Power BI report and wondered if someone could please help?

Our CRM system hold various donations, each of which have multiple transactions with different dates. I want to add a column into my report (but not in my CRM!) that shows the transaction number from 1 to however many per donation and based on date sorted in order. I was hoping that an Index Column might work, but it doesn't seem to.

So, on the image below, Donation DON0078557 has multiple Transactions sorted in increasing date order. I would therefore like TRAN15467 to show as 1 in the new column, TRAN15468 to show as 2 and so on. This would need to be repated (starting again at 1) for each Donation:

jonclay_0-1638967593616.png

Is there a way to achieve this in Power BI?

Many thanks
Jon



1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@jonclay , a New column in Dax

 

Countx(filter( Table, [donation] =earlier([donation]) && [Date] <= earlier([Date]) ), [Date])

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

7 REPLIES 7
jonclay
Helper IV
Helper IV

I've just discovered that this doesn't work in Direct Query Mode (which I was in). I changed the Mode and this now works. Thank you!

amitchandak
Super User
Super User

@jonclay , a New column in Dax

 

Countx(filter( Table, [donation] =earlier([donation]) && [Date] <= earlier([Date]) ), [Date])

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi there Amit,

Many thanks for your quick reply. I've tried this and I get an error saying "Token Literal expected" on the [Date] after the &&. Do you know why this might be?

Many thanks
Jon

@jonclay , Can you share what you created.  Suggested one seem correct to me

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Amit

Thank you. Please see the image below (using the exact column names rather than date etc):

jonclay_0-1638969725938.png


Many thanks
Jon

@jonclay , That is DAX, not power query formula

 

for power query refer if this can help

https://www.youtube.com/watch?v=7CqXdSEN2k4

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Ah yes, of course! However, when I try to create a new Column in the Modeling tab and then enter the DAX, it doesn't seem to recogise the 'earlier' word.

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.