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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
RajK2
Helper IV
Helper IV

Metrics table auto index number number

I have created metrics table using three column description and sales values

now i need to give serial number using dax formula, pls suggest

column name like product, manager, sales amount

1

2

3

 

thanks

1 ACCEPTED SOLUTION
v-agajavelly
Community Support
Community Support

Hi @RajK2 

Thanks for the update and sharing the visuals. I can see what's going wrong here, the current DAX approach with RANKX over a pre-summarized table (SUMMARIZECOLUMNS) creates a static table that ignores your filters, even though it might look like it's working. That’s why you’re getting repeating index numbers or unexpected results when applying slicers, it doesn’t dynamically adjust to what's visible in the visual.

Try bellow dax to achieve filter-respecting.

Index Measure = RANKX(ALLSELECTED(Metrics), CALCULATE(SUM(Metrics[Sales Amount])), ASC, DENSE)

If you just want row numbers, you can simplify it to

Index Measure = RANKX(ALLSELECTED(Metrics),Metrics[Product],,ASC,DENSE)

This respects the filters from slicers, page-level filters, etc, and it gives you a clean 1, 2, 3, ... index with no need for RAND() or static summaries, it’s dynamic and works in visuals directly.

In case if still your index doesn’t need to change with filters, Power Query's “Add Index Column” is still the cleanest.

_________________________________________________________________________________________________________________________
If this response helps, consider marking it as “Accept as solution” and giving a “kudos” to assist other community members.

Thank you,
Akhil.

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

This measure works

S. No. = ROWNUMBER(ALLSELECTED(Data),ORDERBY(Data[Date Presented]))

Hope this helps.

Ashish_Mathur_0-1753507346967.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-agajavelly
Community Support
Community Support

Hi @RajK2 ,

Since we haven’t heard back from you, we’ll proceed to close this thread for now. If you continue to experience issues or have any additional questions, feel free to start a new thread in the Microsoft Fabric Community Forum. We’re always here to help and happy to support you.

Regards,
Akhil.

v-agajavelly
Community Support
Community Support

Hi @RajK2 ,

Just looping back once more  we haven’t heard from you on this thread. If the updated RANKX measure helped solve the issue with dynamic indexing and filter responsiveness, that’s great to hear! Otherwise, feel free to drop a quick update if you're still facing any roadblocks  happy to assist further.

Best regards,
Akhil

v-agajavelly
Community Support
Community Support

Hi @RajK2 ,

I’m following up to confirm that all items discussed have been addressed. If there’s anything else you need, I’d be happy to assist.

Regards,
Akhil

v-agajavelly
Community Support
Community Support

Hi @RajK2 ,

Just checking in did the updated RANKX approach work better with your filters and visuals? It should give you that dynamic index you're looking for, but if it's still behaving unexpectedly or needs tweaking for a specific scenario, feel free to share a bit more context. Happy to help get it just right.

Regards,
Akhil.

v-agajavelly
Community Support
Community Support

Hi @RajK2 

Thanks for the update and sharing the visuals. I can see what's going wrong here, the current DAX approach with RANKX over a pre-summarized table (SUMMARIZECOLUMNS) creates a static table that ignores your filters, even though it might look like it's working. That’s why you’re getting repeating index numbers or unexpected results when applying slicers, it doesn’t dynamically adjust to what's visible in the visual.

Try bellow dax to achieve filter-respecting.

Index Measure = RANKX(ALLSELECTED(Metrics), CALCULATE(SUM(Metrics[Sales Amount])), ASC, DENSE)

If you just want row numbers, you can simplify it to

Index Measure = RANKX(ALLSELECTED(Metrics),Metrics[Product],,ASC,DENSE)

This respects the filters from slicers, page-level filters, etc, and it gives you a clean 1, 2, 3, ... index with no need for RAND() or static summaries, it’s dynamic and works in visuals directly.

In case if still your index doesn’t need to change with filters, Power Query's “Add Index Column” is still the cleanest.

_________________________________________________________________________________________________________________________
If this response helps, consider marking it as “Accept as solution” and giving a “kudos” to assist other community members.

Thank you,
Akhil.

danextian
Super User
Super User

hI @RajK2 

Assuming there are multiple tables involve, try something like below

Index Measure = 
VAR vTable =
    SUMMARIZECOLUMNS (
        'Category'[Category],
        'Category'[sort],
        'Geo'[Geo],
        REMOVEFILTERS(),  -- Fully unfilter report context
        "Total_Revenue", [Total Revenue]
    )

VAR Index =
    RANKX (
        vTable,
        [Total Revenue] + ( RAND() * RAND() ),
        ,
        ASC,
        DENSE
    )


RETURN
    Index

RAND() is not necessary but may help with breaking ties

danextian_0-1750679854018.png

 





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.

I am not getting same answer so its repiting each rows with same appears

I want simple I applied multiple filters as i need rows sequence 1,2,3,4,5 without any issues

rolling total.png

 

Thanks!

DataNinja777
Super User
Super User

Hi @RajK2 ,

 

For creating a serial number, I recommend to use Power Query as the best practice, because there is often no inherent business order in a table.

Using Power Query's "Add Index Column" is the superior method because it creates a simple, static index based on the row's position during data import, without needing any sorting logic.

The DAX RANKX function, in contrast, is designed for value-based ranking (e.g., ranking sales from highest to lowest). Using it for a simple serial number is inefficient and forces a sorting logic that may not be meaningful.

Recommended Steps:

  1. In the Power Query Editor, go to the Add Column tab.
  2. Click Index Column and select From 1.
  3. Click Close & Apply.

This approach is simpler, more performant, and better suited for this exact task.

 

Best regards,

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors