Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Friends,
I have data like this
A B C D Amount
1 2 3 4 100
2 3 4 5 900
5 6 7 8 900
Now based on the fieds A B and C I need to decide the amount type.
I have combinations for A and B for one and A,B and C for another amount type.
Can I include two apply map conditions in the same code???
Thanks
Pavan
on the other hand, maybe you meant
tabABCmap:
LOAD * Inline [
A,B,C, amount type
1,1,1,type1
1,1,2,type2
1,1,3,type3
1,2,1,type4
1,2,2,type5
1,2,3,type6
2,1,1,type7
2,1,2,type8
2,1,3,type9
2,2,1,type10
2,2,2,type11
2,2,3,type12
1,3,,type13
2,3,,type14
3,1,,type15
3,2,,type16
3,3,,type17
];
mapABC:
Mapping LOAD
AutoNumberHash128(A,B,C),
[amount type]
Resident tabABCmap
Where C<>'';
mapAB:
Mapping LOAD
AutoNumberHash128(A,B),
[amount type]
Resident tabABCmap
Where C='';
DROP Table tabABCmap;
tabData:
LOAD *,
If(not IsNum(ApplyMap('mapABC', AutoNumberHash128(A,B,C))), ApplyMap('mapABC', AutoNumberHash128(A,B,C))) as [amount type],
If(not IsNum(ApplyMap('mapAB', AutoNumberHash128(A,B))), ApplyMap('mapAB', AutoNumberHash128(A,B))) as [amount type 2];
LOAD Ceil(Rand()*3) as A,
Ceil(Rand()*3) as B,
Ceil(Rand()*3) as C,
Ceil(Rand()*1000) as Amount
AutoGenerate 50;
hope this helps
regards
Marco
Hi pavan,
no, an ApplyMap() can only involve one field - but you can comine two fields into a compound and then check that against your mapping table?
HTH
Best regards,
DataNibbler
mapping table only takes 2 columns, the source and destination (mapped) column, so if your key is A, B, C, D, you should create a combined key of ABCD as SourceColumn and Amount as Destination and then you will map on SourceColumn.
Hi,
maybe this helps?:
tabABCmap:
LOAD * Inline [
A,B,C, amount type
1,1,1,type1
1,1,2,type2
1,1,3,type3
1,2,1,type4
1,2,2,type5
1,2,3,type6
2,1,1,type7
2,1,2,type8
2,1,3,type9
2,2,1,type10
2,2,2,type11
2,2,3,type12
1,3,,type13
2,3,,type14
3,1,,type15
3,2,,type16
3,3,,type17
];
mapABC:
Mapping LOAD
AutoNumberHash128(A,B,C),
[amount type]
Resident tabABCmap;
DROP Table tabABCmap;
tabData:
LOAD *,
ApplyMap('mapABC', AutoNumberHash128(A,B,If(A>2 or B>2,'',C))) as [amount type];
LOAD Ceil(Rand()*3) as A,
Ceil(Rand()*3) as B,
Ceil(Rand()*3) as C,
Ceil(Rand()*1000) as Amount
AutoGenerate 50;
regards
Marco
on the other hand, maybe you meant
tabABCmap:
LOAD * Inline [
A,B,C, amount type
1,1,1,type1
1,1,2,type2
1,1,3,type3
1,2,1,type4
1,2,2,type5
1,2,3,type6
2,1,1,type7
2,1,2,type8
2,1,3,type9
2,2,1,type10
2,2,2,type11
2,2,3,type12
1,3,,type13
2,3,,type14
3,1,,type15
3,2,,type16
3,3,,type17
];
mapABC:
Mapping LOAD
AutoNumberHash128(A,B,C),
[amount type]
Resident tabABCmap
Where C<>'';
mapAB:
Mapping LOAD
AutoNumberHash128(A,B),
[amount type]
Resident tabABCmap
Where C='';
DROP Table tabABCmap;
tabData:
LOAD *,
If(not IsNum(ApplyMap('mapABC', AutoNumberHash128(A,B,C))), ApplyMap('mapABC', AutoNumberHash128(A,B,C))) as [amount type],
If(not IsNum(ApplyMap('mapAB', AutoNumberHash128(A,B))), ApplyMap('mapAB', AutoNumberHash128(A,B))) as [amount type 2];
LOAD Ceil(Rand()*3) as A,
Ceil(Rand()*3) as B,
Ceil(Rand()*3) as C,
Ceil(Rand()*1000) as Amount
AutoGenerate 50;
hope this helps
regards
Marco