Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
You can use it in an expression as well:
wildmatch('$(vEventLink)','*'&link_id&'*')
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
];
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.
You can use it in an expression as well:
wildmatch('$(vEventLink)','*'&link_id&'*')
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 🙂