Forum Discussion

SBC's avatar
SBC
Helper III
1 year ago
Solved

Index Column Based on Filtered Data in Table Visual

Hi

I have a table visual with three columns of data in Power BI, and I would like to add an index column that starts from 1 and increments by 1 up to the number of rows in the Name column. Specifically, when the data in the table is filtered, the index column should update to reflect the number of rows in the filtered result.

Name- calculated column from app table and contains duplicates

Age- measure

City- measure

Index- start the sequence from 1 and ends at the no of rows of the name column in the table visual. Duplicates should not effect the sequence.

Sample Data (Before Filtering):

Index

Name

Age 

City

1

John

25

New York

2

 Alice

26 

London

3

Bob 

22 

Tokyo

4

John

28 

Berlin

5

Michael

15 

Sydney

Sample Data (After Filtering for "Age > =25"):we use slicer for the filter purpose

Index

Name

Age

City

1

John

25

New York

2Alice26London
3

John

28 

Berlin

 

As you can see, the index should reset based on the filtered data, providing a new row number for each filtered result.

Could someone suggest the best way to implement this dynamic index in my Power BI report? Thank you!

 
  • SBC ,

    try this measure,

    Index Measure = RANKX(ALLSELECTED('Sample'),CALCULATE(MAX('Sample'[Age ])),,ASC,Dense)

1 Reply

  • Arul's avatar
    Arul
    Super User

    SBC ,

    try this measure,

    Index Measure = RANKX(ALLSELECTED('Sample'),CALCULATE(MAX('Sample'[Age ])),,ASC,Dense)