Calculate row number in Data Explorer
It can often be handy to have row numbers when viewing data in tabular form, to display information or to use in calculations.
Let’s take a look at how we can calculate row numbers in the Data Pipeline in order to generate a Table chart similar to the one below:
To add a column with the row numbers to your chart, open a chart using the Edit Chart Data option from the chart menu on your dashboard. Then, in the Data Pipeline, click the +Add Transformation or + button in the and click on Add Column.
Then, in your Pipeline step, select Custom formula as the Formula Type and enter the following as your custom formula in the Formula field:
rowid
Click Apply & Close and your new column will be added.
Rowid column placement
If you want your new rowid column to be the first column in your chart, simply add a Reorder Columns Pipeline Step and move your new column to the top of the column list to be in position #1.
Rowid order
Your rowid values will start at 1 and be calculated according to the order of your rows at the time you add the Add Column Pipeline step.
If you would like your rowid values to be populated based on a different row order, just add a Sort Rows Pipeline step before the Add Column Pipeline step to reorder your results.
Once you do this, the Add Column step with your rowid formula will automatically be adjusted. Simply save your chart to save your changes.
Tip: You can use this rowid column in a number of ways, for example as part of a CASE statement to set conditions depending on the rowid value or in a Filter Rows in the pipeline to include or exclude some rows.