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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Syndicate_Admin
Administrator
Administrator

Index column according to another field

I need to number a table based on data from another field, for example:

INDEX FIELD

A 1

A 2

A 3

B 1

B 2

C 1

C 2

C 3

What can I use to number the index field considering the first field?

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @Syndicate_Admin ,

 

According to your needs, you can try the following dax formula to group and number the fields through index. The reference is as follow:

Col_gorup = 
VAR CurrentValue = Sheet2[Index]
RETURN
    COUNTROWS (
        FILTER (
            CALCULATETABLE ( Sheet2, ALLEXCEPT ( Sheet2, Sheet2[Column1] ) ),
            Sheet2[Index] <= CurrentValue
        )
    )

vhenrykmstf_0-1626145492821.png

 

If the problem is still not resolved, please provide detailed error information and your expected result. Looking forward to your reply.

 

Best Regards,
Henry


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

View solution in original post

4 REPLIES 4
v-henryk-mstf
Community Support
Community Support

Hi @Syndicate_Admin ,

 

According to your needs, you can try the following dax formula to group and number the fields through index. The reference is as follow:

Col_gorup = 
VAR CurrentValue = Sheet2[Index]
RETURN
    COUNTROWS (
        FILTER (
            CALCULATETABLE ( Sheet2, ALLEXCEPT ( Sheet2, Sheet2[Column1] ) ),
            Sheet2[Index] <= CurrentValue
        )
    )

vhenrykmstf_0-1626145492821.png

 

If the problem is still not resolved, please provide detailed error information and your expected result. Looking forward to your reply.

 

Best Regards,
Henry


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

Hello!!!

I need to do exactly the same thing, but I need to transform the data in Power Query. Would I need to replicate that same formula but in M language?

Thank you for your help, greetings!

mahoneypat
Microsoft Employee
Microsoft Employee

Please see this video for one way to do this.

Add index to subgroups in Power Query - YouTube

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Syndicate_Admin
Administrator
Administrator

You can try the LOOKUPVALUE() function, which is similar to excel's VLOOKUP(). I leave the microsoft link where they detail the operation of this function.

The first argument is the column of the table from which you expect the value to be returned, the second is the column by which you will enter with your known value and the third is the known value with which you expect the one you want to return.

https://docs.microsoft.com/en-us/dax/lookupvalue-function-dax

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors