I have a dataset with the following columns
| RowId | FirsName | LastName | PID | Key | Other1 | Other2 |
| 1 | John | Doe | 18177 | K1 | -- | -- |
| 2 | John 2 | Doe 2 | 18177 | K1 | | |
| 3 | John 3 | Doe 3 | 18178 | K1 | | |
| 4 | John 3 | Doe 3 | 18177 | null | | |
| 5 | J2 | D2 | 18177 | null | | |
| 6 | J3 | D3 | 18178 | null | | |
| 7 | G1 | B1 | 19155 | K2 | | |
| 8 | G2 | B2 | 19155 | K2 | | |
| 9 | G2 | B2 | 19155 | null | | |
The requirement is
- Group the dataset by column "Key"
- Identify the unique "PID" value
- Go back to the full dataset and search for all records with Unique PID value for each "Key" group
- Add these records to the "Key" group
e.g.
group by Key "K1", RowId 1,2,3 will be selected.
PID 18177 and 18178 are the unique PID
Going back to the dataset 18177 has 2 additional rows Row 4 and Row 5
This needs to be added back to the group Key "K1"
I dont know if this is possible but wanted to check experts..