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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Index in DAX

Hi All,

 

I want a dynamic DAX that can show me sequential numbers for all my records in table KPI.

The table can be filtered using slicers and so the index should change dynamically.

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can try the following measure to show the dynamic index.

RowNum = 
CALCULATE (
    COUNT ( 'Table'[ID] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[ID]  <= MAX ( 'Table'[ID]  )
    )
)

result dynamic index.gif

 

You can check more details from here.

 

 

Best Regards,

Stephen Tao

 

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-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can try the following measure to show the dynamic index.

RowNum = 
CALCULATE (
    COUNT ( 'Table'[ID] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[ID]  <= MAX ( 'Table'[ID]  )
    )
)

result dynamic index.gif

 

You can check more details from here.

 

 

Best Regards,

Stephen Tao

 

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

amitchandak
Super User
Super User

@Anonymous , In case of Dax Index, would be Rank most of the time. Rank can column Rank static and Measure Rank Dynamic. But Measure rank to Dynamic, you can use allselected. Also, measure rank is context-sensitive

 

City Rank = RANKX(all(Geography[City]),[Sales]) // Work for City both with City ID all city Rank is 1
Geography Rank = RANKX(all(Geography),[Sales]) // Work with both CIty and City ID , both are the lowest level
City and ID Rank = RANKX(all(Geography[City],Geography[City Id]),[Sales])// Work with both CIty and City ID

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415

Greg_Deckler
Super User
Super User

@Anonymous - If you want a specific solution, paste in some sample data as text.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

@Anonymous - It exists, I created it. https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Mythical-DAX-Index/m-p/1093214#M528

 

There are also techniques using RANKX although they tend to product duplicates. There are mitigation methods using small random numbers to break ties.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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