cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper I

Giving a number as an identifier of all text strings between two irregularly recurring text strings

Hi, I have a column of data, that repeats text "a" at irregular inervals, I need to give a number to every "a" and the same number for every other text between "a" and the next "a", see below. The value of "a" should increase by 1 at every instance of "a". Hopefully there is a simple solution, which I am missing! 🙂 I tried creating a index, then using DAX, but haven't been able to solve it.

Col               Number

a                   1

b                   1

a                   2

b                   2

c                   2

a                   3

b                   3

2 ACCEPTED SOLUTIONS
Super User

create an index column. then use below DAX to create another column

``Count = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Column1]=EARLIER('Table'[Column1])&&'Table'[Index]<=EARLIER('Table'[Index])))``

Proud to be a Super User!

Community Support

You can try to use rankx function to build a calculated column.

Add an index column in Power Query Editor by index function.

Then build a number column.

``````Number =
RANKX(FILTER('Table','Table'[Col]=EARLIER('Table'[Col])),'Table'[Index],,ASC)``````

Result is as below.

Best Regards,

Rico Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 REPLIES 2
Community Support

You can try to use rankx function to build a calculated column.

Add an index column in Power Query Editor by index function.

Then build a number column.

``````Number =
RANKX(FILTER('Table','Table'[Col]=EARLIER('Table'[Col])),'Table'[Index],,ASC)``````

Result is as below.

Best Regards,

Rico Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User

create an index column. then use below DAX to create another column

``Count = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Column1]=EARLIER('Table'[Column1])&&'Table'[Index]<=EARLIER('Table'[Index])))``

Proud to be a Super User!

Announcements

Power BI Monthly Update - June 2024

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

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors
Top Kudoed Authors