Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have data as below.
ID | Type | Name | New ID column |
1 | Parent | ABC | 1 |
2 | Child | ABC | 1 |
3 | Child | ABC | 1 |
I want to create the new ID column where, based on the name, I want the Parent ID to be allocated.
New ID will have '1' as this the Parent ID in the above example.
Thank you much.
Do you mean 3rd Column is 'Parent Name'? and based on that you want to have new ID column mapped to Parent name? What if Names(3rd column) are duplicate in your data? Many parents can have same name?
You can use mapping table like this if you ignore duplication in parent names -
_id_name_map:
Mapping load
Name,
ID
resident <yourdatatable>
;
and then somewhere in your reload you use
applymap('_id_name_map',Name) as Parent_ID
Yeah - 3rd column is Parent name and there will be dupes.Onluy Parent ID (1ST COLUMN ) is unique and based on Type column, I want the NEW ID column to have the Parent ID.
I think we don't have enough information to find Parent ID from a child row. We just got 'Name' and on that basis if we try to read other rows with 'Parent' type we might end up getting multiple duplicate parents and won't be able to decide which one is the right parent.