Assign an Autogenerated Row Number to a Repeating Field - Greg Collins

InfoPath Dev

This Blog


Greg Collins

Assign an Autogenerated Row Number to a Repeating Field

If you want to display a row number on a repeating table you can use an Expression Box with the XPath set to position(). This is great if all you want to do is show the row number. But if you actually want to store the sequential autonumber in a field, there's a different XPath you can use.

We will assume that you have the following structure representing your table row:


We will also assume that you want my:Number to be automatically populated with the row number, while staying continually updated as rows are inserted and removed.

  1. Double-click the Number field in the repeating table.
  2. On the Data tab of the Text Box Properties dialog box, ensure that the Update This Value When The Result Of The Formula Is Recalculated check box is selected.
  3. Click the Insert Formula button to the right of the Default Value text box.
  4. In the Insert Formula dialog box, type the following formula:

    count(../preceding-sibling::my:Row) + 1

  5. Click OK twice.

Now preview your form and try it out. Whether you insert or remove rows, each Number field has the correct row number stored in it.

To learn more about position() and other ways of numbering table rows, be sure to check out my example form: Identifying a Filtered Table Row Number.

©2004 Greg Collins. All rights reserved. Licensed to Autonomy Systems, LLC for display on



Niroshan said:

count(../preceding-sibling::*/my:Index_Count) + 1

June 12, 2010 6:47 AM

mahakbhalla said:

Hi, I have a repeating table that is bound to a sharepoint list. I want to limit the number of rows retrieved in repeating table to 3 for the user name selected in drop down (also bound to sharepoint list column). Please help... its urgent.

July 1, 2010 3:09 AM

bphall74 said:


  I followed your instructions, still not getting my RowNumber field to count properly.  Here's my formula

count(../preceding-sibling::*/RowNumber) + 1

I'm still a newbie at this, not sure if I've got it right.

December 30, 2014 5:56 AM

rjj88 said:

Can this be done with letters?

May 21, 2015 2:21 AM

jack eagly said:

Can this be donw with letters?

June 5, 2015 10:20 AM
Copyright © 2003-2018 Qdabra Software. All rights reserved.
View our Terms of Use.