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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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









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


Proud to be a Super User!









"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

 

 










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


Proud to be a Super User!









"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









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


Proud to be a Super User!









"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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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