How To Add Row Numbers

There are times you want to see row numbers in your results — a cumulative count column starting at 1 and increasing down the column. A combination of two Analytics Edge macro functions makes this possible.

Adding a Count Column

One of the options on the Duplicates function is to add a Count column to the results. Normally this would count the number of duplicate values found in your table, but if you select ALL of the columns, which should be unique, it will result in a Count column full of 1’s.

Adding Them Up; Cumulative Sum

The next step is simply to perform a cumulative sum to the column — something the Calculate function can do easily. Calculate > Replace Existing Values, the pick the Cumulative option, Sum, Down the columns and pick the Count column By Name. I recommend you pick the column By Name since macros tend to change over time, and the Count column will tend to move if you add or remove any columns in your original query.

That’s it — you now have a cumulative count column full or row numbers!