Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
BARC’s The BI Survey 19 makes it official. BI users love Qlik. GET REPORT
Partner
Partner

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.

1 Solution

Accepted Solutions
Partner
Partner

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

You can use it in an expression as well:

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

 

image.png

Plees ekskuse my Swenglish and or Norweglish spelling misstakes

View solution in original post

4 Replies
Partner
Partner

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

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

Plees ekskuse my Swenglish and or Norweglish spelling misstakes
Partner
Partner

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

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.

Partner
Partner

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

You can use it in an expression as well:

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

 

image.png

Plees ekskuse my Swenglish and or Norweglish spelling misstakes

View solution in original post

Partner
Partner

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

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 🙂