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: 
Anonymous
Not applicable

How to compare two values in If-statement

Hi all, 

 

In the below job, I try to separate rows from a delimited (.csv) file, so that only the rows where "Project_Stadium_Nieuw" and "Project_Stadium_Gisteren" are different, will continue. 

Therefore I first use tFlowToIterate and subsequently put them again in Global Variables, including the Current Iteration number. And then I want to only let through the ones that have these different values. So I use this statement: 

 

(Boolean)(((String)globalMap.get("Project_Stadium_Nieuw"+((Integer)globalMap.get("tFlowToIterate_1_CURRENT_ITERATION")))) != ((String)globalMap.get("Project_Stadium_Gisteren"+((Integer)globalMap.get("tFlowToIterate_1_CURRENT_ITERATION")))))

 

But.. then everything goes through... While I deliberately put some differences in the input file. What am I doing wrong? Or should I set it up differently? 

Please, your advice and tips are more than welcome! Thanks in advance!

 

0683p000009Lqqg.png

Labels (2)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

Hi,
1st you don't need to compare tFlowToIterate_1_CURRENT_ITERATION with itself. So, you can eliminate this part.
2nd you can't use "!=" or "=" for String comparison. You need to use this syntax:
((String)globalMap.get("Project_Stadium_Nieuw")).equals((String)globalMap.get("Project_Stadium_Gisteren"))

Should works.
However, using a tFilterRow or a tMap with a filter expression would be better (no need to transform flow to global and reverse).

Hope this helps.

View solution in original post

3 Replies
Théo_Cap
Contributor III
Contributor III

Hello,

What is the main purpose of your job ?

I mean what is exactly your input and what do you want in your output ?

TRF
Champion II
Champion II

Hi,
1st you don't need to compare tFlowToIterate_1_CURRENT_ITERATION with itself. So, you can eliminate this part.
2nd you can't use "!=" or "=" for String comparison. You need to use this syntax:
((String)globalMap.get("Project_Stadium_Nieuw")).equals((String)globalMap.get("Project_Stadium_Gisteren"))

Should works.
However, using a tFilterRow or a tMap with a filter expression would be better (no need to transform flow to global and reverse).

Hope this helps.
Anonymous
Not applicable
Author

Thanks! I knew it should be something simple! changing the expression to .equals fixed it!