Forum Discussion
Replace duplicates with null
Hi PI2023,
I think I've achieved what you need. Below what was starting point, I know you have a much bigger dataset but I thought that I'd show you it basic and you could cater it to your scenario. I just made some dummy data, with letters where some are duplicate and some not. I sorted it to show you a visual of how to do this.
Firstly, I added an index column starting from 1.
Then I added a custom column, which was just the index row minus 1. This gives you the previous row value.
Next I merged the query onto itself, referencing the previous row on the original query and the index on the new one.
Expand out the merge, by bringing only the original value column.
Then I added a conditional column, where if the two value columns are equal, then the output would be "null", otherwise bring over the original value.
Lastly, I removed all the unwanted columns, which has given the result of any duplicate with a null value.