Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to copy column from one table to another table using qvw?


Hi,

I have data as below in excel files

Excel A:

                                                                              

CIDProductNameSaleAmountADNumber
235435Sarfach tyu2345563443634
235435Sarfach in US5325449075343
235435Sarfach at the Cafeteria74568969596
534555Roboti345434590876
534555Roboti454534590876
534555Roboti at the caveman islands90780978459287
534555Roboti89066066778
453553Yuorti34363503262384
453553Yuorti5364930347833

Excel B:                                

                               

CUSIDName1INCountAnumber
235435Sarfach tyu38434325563443634/9083254-A
235435Sarfach in US86465655449075343
235435RYIB1209069XX
235435Uipo1209070XX
235435Asda1209071XX
235435Tesco1209072X5635653
235435Iopiu1209073547367900
235435Lidloou120907463190726
235435Pouitr1209075528689
534555Roboti124523434590876/9085876-
534556YUIpi12242434453452342
534557Roboti at the caveman islands123343480978459287
534558Roboti129076599908uh/ophi890876
453553Yuorti800248463503262384
453553Yuorti8009777930347833
453553Yuorti80064475234547653
453553Yuorti241431484463574

I need to get INCount into Excel A where CID and CUSID, ProductName and Name1, ADNumber and Anumber are matching using qvw. Would it be possible. I have tried it but when I select CID = 235435 it is showing all INCount values. But only I need is the INCount value where match exists.

Also there are values separated by '/','-', text values in Anumber eventhough if there are '/', '-' text values when ever the macth exists as  5563443634 = 5563443634/9083254-A I need INCount into Excel A. Is it possible?

Please can anyone suggest me.

Thanks.

8 Replies
marcus_sommer

Try something like this:

excelB_0:

Load CUSID, Name1, InCount, subfield(Anumber, if(index(Anumber, '/') > 0, '/', '-')) as Anumber From excelB;

excelB_1:

Mapping Load distinct CUSID & '|' & Name1 & '|' & Anumber as xlsKey, InCount Resident excelB_0;

excelA:

Load

    CID, ProductName, SaleAmount, ADNumber,

    applymap('excelB_1', CID & '|' & ProductName & '|' & ADNumber, '#NV') as InCount

From excelA;

drop tables excelb_0;

- Marcus

Not applicable
Author

Thanks. It is working only for some cases not all. even though there is value in INCount but it is not populating for some cases and showing as #NV.

Please can help me do I need to change anything here.

marcus_sommer

To receive some #NV meant that not all Keys couldn't be matched. This isn't necessarily wrong and it will depend on the quality from this data how often it occured. If you are sure that a certain Key is in bothe tables available and won't be matched then have look on this keys - maybe there are further delimiter or the fields need some cleaning with trim or similar.

- Marcus

Not applicable
Author

Thanks. Can you help me how to use trim?  please

marcus_sommer

Trim is quite easy to use, simply wrapping the field or expression - but it could be that you have to apply trim to all fields which are you used for the key:

excelB_0:

Load CUSID, Name1, InCount, subfield(Anumber, TRIM(if(index(Anumber, '/') > 0, '/', '-'))) as Anumber

From excelB;

- Marcus

edi
Employee
Employee

Let me know if this works for you.

Not applicable
Author

Thanks. Sorry it is not working. INCount is not showing values.

edi
Employee
Employee

There are values. The blanks are where the CID and CUSID and ProductName and Name don't match, and the ADNumber does not exist in Anumber. Should we have an INCount when only the ADNumber exists in the Anumber?