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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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

4 REPLIES 4
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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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