Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have one field called "FlagValues" which contains values like following
FlagValues
----------------
2010
2011
12345
2013
56789
Now my requirement is I want to create a field during load time
if(len(FlagValues)=4, 'Flag1',
if(len(FlagValues)=5,'Flag2',
if(len(FlagValues)=4 or len(FlagValues)=5,'Both'))) as FlagIndicator
Now when I select Flag1 in UI then only 2010,2011 and 2013 would be select and if select Flag2 then only 12345 and 56789 would be select in FlagIndicator Field. And Finall If select both then all the values would be associted in FlagIndicator.
Plz help.
if(len(FlagValues)=4, 'Flag1',
if(len(FlagValues)=5,'Flag2',
if(len(FlagValues)=4 or len(FlagValues)=5,'Both'))) as FlagIndicator
The first two conditions will catch the lengths 4 and 5, so the last branch (4 or 5) is never reached. A field in a record can have only one value. You seem to want to give it two values. That's not possible. You will have to create additional records:
MyTable:
LOAD
if(len(FlagValues)=4, 'Flag1',if(len(FlagValues)=5,'Flag2')) as FlagIndicator,
...other fields...
FROM ...;
Concatenate(MyTable)
LOAD 'Both' as FlagIndicator
...other fields...
Resident MyTable
Where FlagIndicator=1 or FlagIndicator=2;
Create a link table like this:
Input:
load * Inline [
FlagValues
2010
2011
12345
2013
56789
];Link:
Load
FlagValues,
if(len(FlagValues)=4, 'Flag1',
if(len(FlagValues)=5,'Flag2')) as FlagIndicator
Resident Input;
Load
FlagValues,
'Both' as FlagIndicator
Resident Input;
PFA
Try this as well -
Source:
Load * Inline [
FlagValues
2010
2011
12345
2013
56789 ];
Load * Inline [
Flag
Flag4
Flag5
];
Load if(len(FlagValues)=4, FlagValues) as Flag4,
if(len(FlagValues)=5, FlagValues) as Flag5,
if(len(FlagValues)=4 or len(FlagValues)=5,FlagValues) as FlagIndicator
Resident Source;
Expression in output listbox -
=if(GetFieldSelections(Flag)='Flag4',Flag4,if(GetFieldSelections(Flag,',')='Flag4,Flag5',FlagIndicator,Flag5))