Within datasets, having a unique identifier for each of your rows/records can be important. In my latest internal client project, I needed to complete a fill down on different fields within a table based on its inherit ordering. To do so, I needed to get that ordering from the table to be able to do the task.
If you are using a .csv or .xlsx file, then the process to get the row number is fairly straight forward. For example, we can load in the Superstore dataset into a workflow in Tableau Prep.
Once we have it there, we can bring in our data. We'll drag the People table into the workflow. Then we can see the data source by clicking on the workflow step that's appeared in the view. From there, we can navigate to the Changes tab. With our flat files, Tableau Prep automatically removes the Source Row Number from the table. But we can simply undo that change by clicking the X. This will then read the row number to the dataset, able to be used for the ordering.

However, when connecting to a different data type (where my issue came from connecting with Microsoft SQL Server), there isn't a Source Row Number field that we can read. But there is a workaround.
Once connected to the data source, you can see that when a specific table has been added into the view, there is no changes (as shown by the lack of any symbols next to the input icon) and the table is full of nulls in need of being filled down.

In the bottom left of the application within the Connections panel, there is an option for a 'Custom SQL' source. Dragging that into the view, we've got a new input step.

Clicking on that, we can navigate to the Custom SQL tab and put in what SQL query we want:
SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [Row ID] FROM [Table Name]
An important distinction from a normal SQL query is that we do not include a semi-colon (;) at the end of the statement. If it is included, then Tableau Prep will throw errors.
This follows the basic structure of a SQL query, with a SELECT and FROM statement, pulling everything from the table of our choice. What's new is the addition of the new field that's named 'Row ID'. For this, we use the window function ROW_NUMBER() over an order of our choice. So what we decide to order on is just the number 1. This retains the inherit order of the table and adds the row number based on that order.

And now that there's the Row ID field, taking the inherit ordering of the table as it is pulled from the server, it's now possible to do a fill down on the null values in the table. And from there, the rest of the workflow and go on as intended.

