Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I need help in the script getting out a list of id:s of merchants from the merchant table to identify if that id should be in a special group.
id;merchant_name
1;m1
2;m2
3;m3
4;m4
5;m5
6;m6
7;m7
8;m8
9;m9
10;m10
the id 1,5,10 companion Group_1
the id 2,3,9 companion Group_2
and all other id:s companion Other
Should I do that as a if statement or is there a more better way to do this in the script?
Thanks ahead!
Hi,
I would always use an if-statement, something like:
Load ...
If(Match(ID,1,5,10),'Group_1',If(Match,ID,2,3,9),'Group_2','Other')) As Groups,
...
From ...;
You can do this with apply map. Your code should be as follows.
Test:
Mapping Load * inline [
ID,Group
1, companion Group_1
5, companion Group_1
10, companion Group_1
2, companion Group_2
3, companion Group_2
9, companion Group_2
];
Load *,ApplyMap('Test',id,'Others') as Group;
Load * inline [
id,merchant_name
1,m1
2,m2
3,m3
4,m4
5,m5
6,m6
7,m7
8,m8
9,m9
10,m10
];
Find the working example with this post.
- Sridhar
Hi,
I would always use an if-statement, something like:
Load ...
If(Match(ID,1,5,10),'Group_1',If(Match,ID,2,3,9),'Group_2','Other')) As Groups,
...
From ...;