Hi,
I have below dataset.
| Account | SECURITY | STAGE | FBE |
| S0001 | SEC9954 | S1 | F1 |
| S0002 | SEC000399 | S1 | F1 |
| S0002 | SEC000399 | S1 | F1 |
| S0002 | SEC000399 | S1 | F1 |
| S0002 | SEC000399 | S1 | F2 |
| S0002 | SEC000399 | S2 | F1 |
| S0003 | SEC12345 | S1 | F1 |
| S0003 | SEC12345 | S1 | F1 |
| S0003 | SEC12345 | S1 | F1 |
| S0004 | SEC4000 | S4 | F4 |
| S0004 | SEC4000 | S4 | F4 |
| S0005 | SEC5000 | S5 | F5 |
| S0005 | SEC5001 | S5 | F5 |
| S0005 | SEC5001 | S5 | F6 |
My Expected output is MasterId column in below output.
| Account | SECURITY | STAGE | FBE | MaserId |
| S0001 | SEC9954 | S1 | F1 | SEC9954_2 |
| S0002 | SEC000399 | S1 | F1 | SEC000399_2 |
| S0002 | SEC000399 | S1 | F1 | SEC000399_2 |
| S0002 | SEC000399 | S1 | F1 | SEC000399_2 |
| S0002 | SEC000399 | S1 | F2 | SEC000399_3 |
| S0002 | SEC000399 | S2 | F1 | SEC000399_4 |
| S0003 | SEC12345 | S1 | F1 | SEC12345_2 |
| S0003 | SEC12345 | S1 | F1 | SEC12345_2 |
| S0003 | SEC12345 | S1 | F1 | SEC12345_2 |
| S0004 | SEC4000 | S4 | F4 | SEC4000_2 |
| S0004 | SEC4000 | S4 | F4 | SEC4000_2 |
| S0005 | SEC5000 | S5 | F5 | SEC5000_2 |
| S0005 | SEC5001 | S5 | F5 | SEC5001_2 |
| S0005 | SEC5001 | S5 | F6 | SEC5001_3 |
Logic is :- If account, security, stage and FBE column value is same then MasterId value should be Security_2 i.e in first row MasterId output should be SEC9954_2
If Account & Security value is same but any other value from stage and FBE is different then masterId value should be incremental. See the row number 5 & 6 masterId value is SEC000399_3 & SEC000399_4 respectively.
Please note incremental value will be start with 2. Any duplicates entries where all the column values are same, masterId concate with "_2".
Thank you