Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Peony
Creator III
Creator III

Exclude rows that partly similar with other rows

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:

Peony_5-1735075847372.png

 



Labels (4)
1 Solution

Accepted Solutions
rubenmarin1

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

View solution in original post

2 Replies
rubenmarin1

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

Peony
Creator III
Creator III
Author

@rubenmarin1 It brilliant! Thank you much for solution and explanation!