Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have xls which contain field called "ID" and it has following values.
ID
ABC
XYZ
QRS
ASP
Basically I want to load the values which are in the xls. If the above values exists in one of the field in the below load statement then value of that field should be X or else it should be Y and name the field as "Flag". FYI, Below data is getting loaded from QVD.
Load *,
if(ValueExits,'X','Y') as Flag
from data.qvd
May be I guess we need to use the apply map but I am not sure.
Can some one please help me out for this. It is little urgent!
If you want to check for existence of the value in a specific, single field of your qvd load (and not if it occures in any of the fields), you can do it like this:
LOAD DISTINCT
ID as ValueToCheck
FROM Excel.xls;
LOAD *,
if(exists(ValueToCheck, ID),'X','Y') as Flag
FROM data.qvd;
where ID is the field you want to compare your values to.
If you want to check for existence of the value in a specific, single field of your qvd load (and not if it occures in any of the fields), you can do it like this:
LOAD DISTINCT
ID as ValueToCheck
FROM Excel.xls;
LOAD *,
if(exists(ValueToCheck, ID),'X','Y') as Flag
FROM data.qvd;
where ID is the field you want to compare your values to.
If you have to check only one field from qvd, it is:
if(exists(ID, Field),'X','Y') as Flag
If there are several fields to check:
if(exists(ID, Field1) or exists(ID, Field2) or exists(ID, Field3) ...,'X','Y') as Flag
Hi,
If you have the ID field in the data.qvd you can solve it in two simple ways.
1. where Exists(ID,ID)
2.
Maping:
Mapping Load
ID
'X'
from your ID table.
then use:
Load *,
if(applymap('Maping', ID,'Y')) as Flag
from data.qvd
//Stabben
Thanks all. Everything looks good.Please give me some time. I will check and update you.
What about all the proposed solutions you already have?
If all these do not work (which I don't believe), can you tell us, what the issue is or how the results differ from your expectation (so you need to post some input data, the script you used, the output you get, and what you expected instead). It's all urgent, for everybody, something.
Hi Swuehl,
Yes the solution did worked. I should have marked as correct answer which I didn't do. Sorry!