Six Stars

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!

 

IfStatement.PNG

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions
Eleven Stars TRF
Eleven Stars

Re: How to compare two values in If-statement

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.

TRF
3 REPLIES
Six Stars

Re: How to compare two values in If-statement

Hello,

What is the main purpose of your job ?

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

Eleven Stars TRF
Eleven Stars

Re: How to compare two values in If-statement

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.

TRF
Six Stars

Re: How to compare two values in If-statement

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