Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have 2 table:
1) table1 have a field called Key as follow:
Key :
if(len(Trim(Product_Code))=0 and Len(Trim(Currency))=0,CDR_Standardized,
if(len(Trim(Product_Code))=0 and Len(Trim(Currency))<>0 ,CDR_Standardized&'|'&Currency,
if(len(Trim(Product_Code))<>0 and Len(Trim(Currency))=0 ,CDR_Standardized&'|'&Product_Code,
(CDR_Standardized&'|'&Product_Code&'|'&Currency)))) as Key
It has values such as :
70648|USD that's associated to an ID=2 for example !
Now the Key in the second table contains values like this:
XXX|70648|USD|02
AA|70648|USD|05
DD|70648|USD
70648|USD|1919|EST
so; the ID=2 is obviously not associated with :
XXX|70648|USD|02
AA|70648|USD|05
DD|70648|USD
70648|USD|1919|EST
The question is: how to do to associate these values since Key from the first table exists in the second?
Thanks a ton !
Thanks a lot !
Any hint stalwar1?
I am going to ask you to take a step back....
Instead of what all you have tried... can you give me few mapping table data and few fact table data... I am just lost in the multiple humongous responses above and not able to work with them
here's the first table:
LOAD * INLINE [
ID, Key, Value1, Value2
3, 70648,50,20
2, USD|70648, Valuex, valuey
4, USD|70648|xx, Valuex, valuey
1, fxFA | EUR, 20,30
];
and the second one:
LOAD * INLINE [
key, otherField
XXX|70648|02, 300
fxFA | EUR, 500
EUR|fxFA|200,200
300|fxFA,10
USD|70648|xx,50
xx|300|USD|70648,100
EUR|500|fxFA,300
AA|70648|05|USD, 500
DD|70648|USD, 200
70648|USD|1919|EST, 150
];
I think u already know what are the results I'm looking for .
Yup, checking...
This worked !
table1:
LOAD *,trim(text(subfield(Key,'|'))) as kw INLINE [
id, Key, Value1, Value2
3, 70648,50,20 //works for this one !
2, USD|70648, Valuex, valuey
4, USD|70648|xx, Valuex, valuey
1, fxFA | EUR, 20,30
];
left join
LOAD Key,count(DISTINCT kw) as keycount
resident table1
group by Key;
table2:
LOAD * INLINE [
key, otherField
XXX|70648|02, 300
fxFA | EUR, 500
EUR|fxFA|200,200
300|fxFA,10
USD|70648|xx,50
xx|300|USD|70648,100
EUR|500|fxFA,300
AA|70648|05|USD, 500
DD|70648|USD, 200
70648|USD|1919|EST, 150
];
left join(table2)
LOAD id,// as idfk,
kw as kw2 resident table1;
table3:
NoConcatenate
LOAD *,if(WildMatch(key,'*'&kw2&'*'),1,0) as ismatch
resident table2;
drop Table table2;
left join
load key,id,sum(ismatch) as countmatch
Resident table3
group by key,id;
inner join(table3)
LOAD id,keycount as countmatch
resident table1;
table2:
NoConcatenate
LOAD distinct key,otherField,id Resident table3;
drop Table table3;
table1bis:
NoConcatenate
load distinct id, Key, Value1, Value2
resident table1;
drop table table1;
rename table table1bis to table1;
stalwar1; this code worked with inline tables:
but when I did the same thing with my tables; it did not...
PLEASE; i'm DESPERATE !! if u know any alternative to do this; PLEASE help ! PLEASE
Checking
I tried to run your script and I get this association
Is this right that the key USD|70648|xx is associated with id 2, 3, & 4? Is this what your goal is that if it finds multiple matches, you want to assign all of them?
check your linkedin inbox