Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
morenoju
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.

Labels (4)
1 Solution

Accepted Solutions
Vegar
Partner
Partner

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
Vegar
Partner
Partner

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
morenoju
Partner
Partner
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
Partner
Partner

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

morenoju
Partner
Partner
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 🙂