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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Add dynamical incremental column for filtered data

Good day,

 

I have a report with slicers and also with filters applied on the visual. I need to add an incremental column with values from 1 to count(number or rows displayed). This range needs to reset when I change the values of the slicers and a different data set is displayed.

I have tried using index column and other formulas suggested on the forum, but none of them displays the range with consecutive numbers. I get different numbers displayed, for example:

omihai_0-1608725675213.png

The formula is: Row_Number =
CALCULATE (
COUNT ( MyTable[Index] ),
FILTER ( ALLSELECTED (MyTable ), MyTable[Index] <= MAX ( MyTable[Index] ) )

 

Does anyone have an idea? Thank you.

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

I will post the answer here so you can accept and hel others.

 

Add the following measure and change your Row Number to the code below:

 

ID_SUM_Group =
SUMX ( MyTable, SUM ( MyTable[Index] ) )

 

Since there can be more than one index on your context for the table visualization you need to do the following Row Code:

Row_Number =
VAR Row_Number_Filter = [ID_SUM_Group]
VAR temp_table =
    SUMMARIZE (
        ALLSELECTED ( MyTable),
        MyTable[Column1],
        MyTable[Column2],
        MyTable[column3],
        ...,
        MyTable[ColumnN],
        "Row_number", [ID_SUM_Group]
    )
RETURN
    COUNTROWS ( FILTER ( temp_table, [Row_number] <= Row_Number_Filter ) )

 

In the summarize function you need to place all the columns you have on the table visualization giving context, be aware that you may not need all of the columns so in some cases you can have a shorter summarize function since so of the columns aren't needed example if you have a ID and ID description you can only use the ID since they both relate to the same information.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

9 REPLIES 9
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

 

Measure = 
CALCULATE(
    COUNT(Sales[Index]),
    FILTER(
        ALLSELECTED(Sales),
        [Index] <= MAX([Index])
    )
)

 

v-lionel-msft_0-1608862839799.png

 

I didn't reproduce your problem, please provide the sample .pbix file or sample data model.

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

Hi @MFelix , @amitchandak ,

 

Thank you for your suggestions. After adding the index and changing the formula I get non consecutive numbers for the column Line Number. For example, it jumps from 10 to 12..

 

omihai_0-1608728132980.png

 

Hi @Anonymous ,

 

This have to do with context the example I have is based on the entire table so this can cause different issues due to the way the calculations are made.

 

Can you share a sample data? So I can check what is the adjustments to be made. also can you share the expected result?


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Hi @MFelix  I have sent you the samle data. Thank you.

Hi @Anonymous ,

 

I have sent you a private message with the answer can you please check it and tell me if it works so I can post it here so it can help others.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Hello @MFelix , sorry for the delayed reply. I have tested the fix and it works, thank you very much.

Hi @Anonymous ,

 

I will post the answer here so you can accept and hel others.

 

Add the following measure and change your Row Number to the code below:

 

ID_SUM_Group =
SUMX ( MyTable, SUM ( MyTable[Index] ) )

 

Since there can be more than one index on your context for the table visualization you need to do the following Row Code:

Row_Number =
VAR Row_Number_Filter = [ID_SUM_Group]
VAR temp_table =
    SUMMARIZE (
        ALLSELECTED ( MyTable),
        MyTable[Column1],
        MyTable[Column2],
        MyTable[column3],
        ...,
        MyTable[ColumnN],
        "Row_number", [ID_SUM_Group]
    )
RETURN
    COUNTROWS ( FILTER ( temp_table, [Row_number] <= Row_Number_Filter ) )

 

In the summarize function you need to place all the columns you have on the table visualization giving context, be aware that you may not need all of the columns so in some cases you can have a shorter summarize function since so of the columns aren't needed example if you have a ID and ID description you can only use the ID since they both relate to the same information.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix
Super User
Super User

Hi @Anonymous ,

 

You need to use a technique similar to the one I used on the post below:

 

https://community.powerbi.com/t5/Desktop/How-to-add-a-Serial-Row-Number-Column-in-Power-BI-Table-Matrix/m-p/208735

 

This is similar to your measure however I'm counting the number of rows that preceeds the value, be aware that for this type of solution you need to add the INDEX column no your visualization.

 

Redoing your measure should be similar to this:

Row_Number =
CALCULATE (
    COUNTROWS ( MyTable ),
    FILTER ( ALLSELECTED ( MyTable ), MyTable[Index] <= MAX ( MyTable[Index] ) )
)

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



amitchandak
Super User
Super User

@Anonymous , this is the correct formula and should respond to changes with a filter. Can share a screenshot of the issue.

 

Also, vote for the idea

Serial No in Visual Table
https://ideas.powerbi.com/ideas/idea/?ideaid=80612ec5-14a9-4929-a2ee-531943fa51d4

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.