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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Bryanna
Helper II
Helper II

Line Number in Table

Hi,

 

Looking for some help! I need to add a line number to a table in PBI, however, everything i try is too slow to populate even when i have it filtered with just a handful of options. I created an index in power query and then used the below measure. I need this to be dynamic when they filter in the report and i only have the order number to rank off of. Any tips would be appreciated!

 

Row number = CALCULATE(COUNTROWS('Order Rank'),FILTER(ALLSELECTED('Order Rank'),'Order Rank'[Rank]<=MAX('Order Rank'[Rank])))
 

Bryanna_1-1751051632337.png

 

1 ACCEPTED SOLUTION

Hi @Bryanna ,

Thank you for your response. Please share sample PBIX file. It will help me to replicate the scenario.

 

Regards,

Dinesh

View solution in original post

10 REPLIES 10
v-dineshya
Community Support
Community Support

Hi @Bryanna ,

Thank you for reaching out to the Microsoft Community Forum.

 

You are trying to create a dynamic row number in Power BI when filter in the report based on "Order  Number".

 

Please follow below steps.

 

1.  I have created table "Table" based on your sample data. refer snap.

 

vdineshya_0-1751269878078.png

 

2.  Created measure "Row Number" with below DAX , it will create dynamic row number.

 

Row Number =
CALCULATE(
    COUNTROWS(
        FILTER(
            ALLSELECTED('Table'[Order Number]),
            'Table'[Order Number] <= MAX('Table'[Order Number])
        )
    )
)
 
3.  Please refer output snap and attched PBIX file for your reference.
 
vdineshya_1-1751270297651.png

 

If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.  Please do let us know if you have any further queries.

 

Regards,

Dinesh

 

 

Hi @Bryanna ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.

 

Thank you.

Hi @Bryanna ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.

 

Thank you.

Apologies on the delay. We ended up having to do a new visual calculation and entered a 1 and then did a runningsum calculation off of that. The only stipulation is there is no total at the bottom.

 

What you had provided worked for a small number of entries but due to the amount of data in the pbi , it wouldnt work for this scenario.

 

Bryanna_0-1751915107947.png

Bryanna_1-1751915165454.png

 

Hi @Bryanna ,

Thank you for your response. Please share sample PBIX file. It will help me to replicate the scenario.

 

Regards,

Dinesh

Hi @Bryanna ,

We haven’t heard from you on the last response and was just checking back . Please share sample PBIX file. It will help me to replicate the scenario.

 

Regards,

Dinesh

FBergamaschi
Super User
Super User

Plase clarify if you are looking for a calculated column (a static thing) or a measure (dinamic thing). Assume you are looking for a measure but just to be sure. 

 

More importantly, please provise a sample of the table and a clear explanation of what you want to rank: you want to rank the order nr in an asceding way? And you want the ranking to be based only on the visible values in the matrix?

 

And what is the issue you have with your formula in use?

 

Best

FB

Bryanna
Helper II
Helper II

I keep receiving this error but there are no duplicate order numbers in the table.

 

A single value for column 'Order Number' in table 'Order Rank' cannot be determined. This can happen when a measure or function formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

This error is due to a missing row context, please check v-dineshya answer, maybe that solved already

 

MasonMA
Super User
Super User

@Bryanna , Hi, you may try 

Row Number = 
RANKX(
    ALLSELECTED('Order Rank'),
    'Order Rank'[Order Number],
    ,
    ASC,
    DENSE
)

 

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.