Replace/Simplify row values to eliminate duplicates

This thread and the discussion might be relevant for you: