Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I am new to QV. I was learning about Mapping table and found that the table that is being mapped (Table A in below example) always has two fields in it.
For example, Table A has fields x and y, and Table B has fields x,a,b,c.
We do
TableA_Map:
Mapping LOAD x, y
and in Table B:
LOAD applymap('TableA_Map', x) as y, a,b,c
My question is will MAPPING only work if there are just two fields in TableA as we do not specify which field from Table A in the apply() function.
I hope my question is clear.
Thanks
Raj
Hi Raj,
The rules for a mapping load are (i) 2 fields only and (ii) first field in mapping load statement has to be the linking field.
Naturally, your source table can contain more than 2 fields, but when using the "mapping load" statement, there can only be 2 fields in that load statement.
Only alternative to this is a join. However, the distinct advantage of the applymap is that you can call for an external field to be loaded during the load process, which opens up quite a bit of avenues rather than loading tables, left joining and then reloading the original tables with further transformations.
Hope this helps.
Hi Raj,
The rules for a mapping load are (i) 2 fields only and (ii) first field in mapping load statement has to be the linking field.
Naturally, your source table can contain more than 2 fields, but when using the "mapping load" statement, there can only be 2 fields in that load statement.
Only alternative to this is a join. However, the distinct advantage of the applymap is that you can call for an external field to be loaded during the load process, which opens up quite a bit of avenues rather than loading tables, left joining and then reloading the original tables with further transformations.
Hope this helps.
Thank you CheenuJanakiram. I guess I overestimated the usefulness of Mapping table.
Hi Raj,
mapping load is nothing more than the equivalent of Excel's vlookup. It helps in some instances.
Say I have product price in Product table and Quantity sold in TXN table. I want to generate price * quantity for sales value.
With applymap you can do a mapping load of the price from products table, then in the TXN table you say applymap(etc.) * quantity as SalesValue.
If there was no applymap, then you most probably would have to load TXN, load product, left join product to TXN, reload new TXN with the price * quantity and then drop the original TXN. More headache than is required.
Hence, when you are just peeling out one value from a table and attaching to another, the applymap is a useful tool. Otherwise, just do a join if there are more than one field that you want to attach to one table from another.