Hello @Hrvoje Somun? , thank you for your question.
Regarding the first step - you'll need to use the fill() function while sorting the columns via the metadata parameter $sourcerownumber. This way, you'll be able to use the original value sorting, while all the empty cells will "look up" to find the first non-empty value.
Regarding the second step to reach the pivot table - this isn't a tabular presentation of the values, and isn't something we do in Trifacta. At least, not without a lot of tinkering, which I do not recommend.
I'd advise creating this pivotal presentation through any BI tool of your choice.
I hope this helps,
Please feel free to ask any additional questions.
Thanks,
Amit.