Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Issue with variable in Qlik Sense

I'm trying to use a variable to check whether or not a certain value exists in a field.

This is what I have:

Let vArchive = If(Match('Archive', 'ArchiveCost'), True(), False())

Archive is a field in a table, and I'm checking to see if ArchiveCost exists as a value.

Right now, it returns False even when the value does exist. Is there a better way to do this than the Match() function?

Thanks!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Ah, you are looking for a script only solution, right? I missed that and posted an expression for the front end.

Try

Let vArchive = If(Exists('Achive','ArchiveCost'),True(),False());

Single quotes around Archive field name are mandatory.

View solution in original post

6 Replies
swuehl
MVP
MVP

Maybe

= If( Sum( Match([Archive], 'ArchiveCost')), True(), False())

NZFei
Partner - Specialist
Partner - Specialist

Temp:
load * inline [
Archive
1,
2,
3,
3,
3,
ArchiveCost
];

AllValuesInArchiveTable:
load
Concat(distinct [Archive], '|') as AllValuesInArchiveField
Resident Temp;

let vAllValuesInArchive = peek('AllValuesInArchiveField',-1,'AllValuesInArchiveTable');
drop table AllValuesInArchiveTable;


Let vArchive = If(index('$(vAllValuesInArchive)', 'ArchiveCost')>0, 1, 0);

Not applicable
Author

This one isn't working, it's returning an error:

Unexpected token: ',', expected nothing: Let vArchive = If(Sum(Match([Archive], 'ArchiveCost'))>>>>>>,<<<<<< True(), False())

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

You Can try this.

Let vArchive = If(wildmatch(Archive, 'ArchiveCost'), True(), False())


Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
swuehl
MVP
MVP

Ah, you are looking for a script only solution, right? I missed that and posted an expression for the front end.

Try

Let vArchive = If(Exists('Achive','ArchiveCost'),True(),False());

Single quotes around Archive field name are mandatory.

Not applicable
Author

Thank you! This one works.