Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a field named Supplier.
The value in Supplier is coming from table A and another mapping table.
I want to create a field named table source where I can identify from which table my values are coming.
Please help me in achieving this.
Below is my second source of data and the other is a straight table -
ApplyMap('Map_Supplier',[Item]&'|'&Company_Code,[Supplier_001]) as [Supplier]
Assume you are trying to create a new filed called "TableSource" in your Final Table, which pull all data into one final table, you can try below to create Final filed [Supplier] from both TableA and Map, and create new filed [TableSource] using same if-else logic.
TableFinal:
Load
if(Len(Supplier)>0, Supplier, ApplyMap('Map_Supplier',[Item]&'|'&Company_Code,[Supplier_001], null()) as [Supplier],
if(Len(Supplier)>0, 'TableA',
if(Len(ApplyMap('Map_Supplier',[Item]&'|'&Company_Code,[Supplier_001], null())>0,'Map_Supplier','Unknown')
) AS [TableSource],
...
Resident TableA_or_JoinAllTable;
Please node, I use null() as DefaultValue when no matching fund in function ApplyMap('map', KeyToFindMach, DefaultValue). Then Len(NULL) = 0 to mark as 'Unknow' Supplier, if any key <[Item]&'|'&Company_Code> has no match in TableA and Map.