Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all. I will be grateful if someone could split some light regarding possible solution of the next task.
I have a field with data as below.
Load * Inline [
NAMELIST
FTA - Farma
GSP - Farma
LOT - Store
LOT - Farma
SOOT - Store
SOOT - Store
ARTT - Farma
ARTT-R - Farma
ARKD-West - Store
ARKD-West - Farma
Pacific - Farma
];
I need to create table where
-all items ended as 'store' should have '1' as indicator,
-all items that ended as 'farma' and have name similar to 'store', shold have '0' as indicator.
-all the rest items should have '1' as indicator.
And unfortunately, I can't get how to make comparison for those items that should be marked as '0'.
Final result should looks like this:
Hi, if you have a tmpNameList with those values (and I suppose one of the 'SOOT - Store' should be a 'SOOT - Farma', this script will do de task:
NameList:
LOAD NAMELIST,
Subfield(NAMELIST,' - Store',1) as chkStoreLoaded,
1 as Ind
Resident tmpNameList
Where Right(NAMELIST,5)='Store';
Concatenate (NameList)
LOAD NAMELIST,
If(Exists('chkStoreLoaded', Subfield(NAMELIST,' - Farma',1)), 0, 1) as Ind
Resident tmpNameList
Where Right(NAMELIST,5)='Farma';
DROP Field chkStoreLoaded;
DROP Table tmpNameList;
You can also use "Left(NAMELIST,Index(NAMELIST,'-',-1)-1)" instead of Subfield.
And in case there are values that doesn't end with Store or Farma, and should have a 1, just add them as:
Concatenate (NameList)
LOAD NAMELIST,
1 as Ind
Resident tmpNameList
Where not Match(Right(NAMELIST,5),'Store','Farma');
Or add the If condition to check for stores with the same name
Hi, if you have a tmpNameList with those values (and I suppose one of the 'SOOT - Store' should be a 'SOOT - Farma', this script will do de task:
NameList:
LOAD NAMELIST,
Subfield(NAMELIST,' - Store',1) as chkStoreLoaded,
1 as Ind
Resident tmpNameList
Where Right(NAMELIST,5)='Store';
Concatenate (NameList)
LOAD NAMELIST,
If(Exists('chkStoreLoaded', Subfield(NAMELIST,' - Farma',1)), 0, 1) as Ind
Resident tmpNameList
Where Right(NAMELIST,5)='Farma';
DROP Field chkStoreLoaded;
DROP Table tmpNameList;
You can also use "Left(NAMELIST,Index(NAMELIST,'-',-1)-1)" instead of Subfield.
And in case there are values that doesn't end with Store or Farma, and should have a 1, just add them as:
Concatenate (NameList)
LOAD NAMELIST,
1 as Ind
Resident tmpNameList
Where not Match(Right(NAMELIST,5),'Store','Farma');
Or add the If condition to check for stores with the same name
@rubenmarin1 It brilliant! Thank you much for solution and explanation!