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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
ebuchholz
Frequent Visitor

Running count of reoccurring values in a column ordered 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
2 REPLIES 2
v-sihou-msft
Microsoft Employee
Microsoft Employee

@ebuchholz

 

According to your description, you are actually need to create a Rank column based on a date column within each ID group. Right?

 

You can create a calculated column like below:

 

RankWithinGroup Column =
RANKX (
    FILTER ( Table, Table[ID] = EARLIER ( Table[ID] ) ),
    Table[Date],
    ,
    ASC,
    DENSE
)

4.PNG

Regards,

Can this be done in the edit queries screen as a column with new values? Ideally I would like to use this value to create a new key for the table it resides in.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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