Hi,
I want to add a Row ID to each row of my text file, to help me with some logic that I need to apply to the data. Suffice to say, this is quite a complex file, which I am splitting into smaller sets and then joining again, and it's imperative that the row order is exactly how it is in the text file. When I view the data in Prep, it is in the correct order.
However, when I use ROW_COUNT funtion with PARTITION funtion, it requires me to order my data first by a dimension. Even if I "sort" by a dimension which only has one value, such as for example "Table names" (yes, I have multiple text files in a union), Tableau assigns a strange sorting to the data, and so my data is reshuffled even though each row is counted once.
Any ideas, how to add Row ID in correct order?
You're touching on one of the core reasons why my org can only use Prep for limited use cases. Prep was designed with more of a SQL database mental model and there is no guarantee that Prep will maintain row order for data that is input or output.
The only option is to add the Row ID in another tool outside of Prep, or theoretically opening the file inside a Script node (which would require you to write R/Python/etc.) and then using that tool to add the Row ID before passing the data downstream.
Here's the feature request for adding row number in incoming record order to Prep: https://community.tableau.com/s/idea/0874T000000HCB8QAO/detail