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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply

Create a rank/index using created date against ID

I have a table where I have multiple TSID's with the same value due to adjustments being made to the original TSID which brings in additional transaction lines.

I would like to identify the original transactions as 0, the first adjustment as 1 and the second adjustment as 2.

Each TSID entry has a different created date so I was hoping to use this to be able to identify which transaction is the original, first adjustment and 2nd adjustment in the example below.

 

created_at_utcTimesheet_TSID
07-03-22 21:56710139
11-10-21 1:38710139
15-10-21 1:18710139

 

So I would like it to look something like this

created_at_utcTimesheet_TSIDAdjustment
07-03-22 21:567101392
11-10-21 1:387101390
15-10-21 1:187101391
1 ACCEPTED SOLUTION

Hi @Thomas-B-Hudson ,

 

Try this:

Rank =
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Date] <= EARLIER ( 'Table'[Date] )
            && 'Table'[ID] = EARLIER ( 'Table'[ID] )
    )
) - 1
//-1 to make the first one zero




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Write this calculated column formula

Adjusted = calculate(countrows(Data),filter(Data,Data[created_at_utc]<=earlier(Data[created_at_utc])))-1

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
danextian
Super User
Super User

Hi @Thomas-B-Hudson,

You can create a calculated column that will count the rows that meet a certain criteria (eg <=to a date). Here's a sample:

 

Rank =
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER ( ALL ( 'Table' ), 'Table'[Date] <= EARLIER ( 'Table'[Date] ) )
) - 1
//-1 to make the first one zero

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian,

This looks to be working in essance, what I am wondering however is I have quite a large dataset which contain these TSID's so you can see from my screenshot below that the values are not 0, 1, 2, etc.

Would you now how to get this formula to reset the count at each new instance of a TSID?

Thanks for your help so far

 

created_at_utc Timesheet_TSID Adjustment
07-03-22 21:56 710139 364813
11-10-21 1:38  710139 308519
15-10-21 1:18  710139 308793

 

Hi @Thomas-B-Hudson ,

 

Try this:

Rank =
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Date] <= EARLIER ( 'Table'[Date] )
            && 'Table'[ID] = EARLIER ( 'Table'[ID] )
    )
) - 1
//-1 to make the first one zero




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Legend!

mahenkj2
Solution Sage
Solution Sage

I would suggest you to refer this link:

https://radacad.com/create-row-number-for-each-group-in-power-bi-using-power-query

 

I think you will need to index based on each TSID. If this is not what you are looking for please revert back.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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