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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
morenoju
Partner - Specialist
Partner - Specialist

Master measure that checks if a field value belongs to a comma separated list

Hi,

I have a master measure that checks if link_id belongs to a comma separated list in a variable called vEventLinks. If it does, it returns '1'.

 

if(link_id=SubField($(vEventLinks),',',1) OR link_id=SubField($(vEventLinks),',',2) OR link_id=SubField($(vEventLinks),',',3) OR link_id=SubField($(vEventLinks),',',4)

etc.

1, null())

 

It is working ok but the way I did it is concatenating conditions using OR. Is there a way to make some kind of loop or anything that would make the master measure cleaner and easier to maintain?

Thanks.

Labels (1)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

You can use it in an expression as well:

wildmatch('$(vEventLink)','*'&link_id&'*')

 

image.png

View solution in original post

4 Replies
Vegar
MVP
MVP

Consider this example script;

SET vEventLink = 1,2,3;

LOAD
	*,
	wildmatch('$(vEventLink)','*'&link_id&'*') as Match
inline [
link_id, DAT, 		AMOUNT
2, 		20160101, 	10
1,		20160101,	11
2, 		20191231,	12
1,		20191231,	13
3, 		20191231,	14
4,		20191231,	15
];

 

image.png

morenoju
Partner - Specialist
Partner - Specialist
Author

Thanks Vegar, but I can't do this at script level!

vEventLink changes depending on other fields selections by the user. So I'm trying to find a better expression for the master dimension.

Vegar
MVP
MVP

You can use it in an expression as well:

wildmatch('$(vEventLink)','*'&link_id&'*')

 

image.png

morenoju
Partner - Specialist
Partner - Specialist
Author

Brilliant! Thanks Vegar!

I removed a couple of ' around the variable:

wildmatch($(vEventLinks),'*'&link_id&'*')

Now in my calculated dimension I'm using:

if(wildmatch($(vEventLinks),'*'&link_id&'*'),
1, null())

Way better than before 🙂