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

If Statement

The code below is not working correctly.

if(TRAN_CD <> 355 and (DFNR_CD = 0 and SUM_TRAN_AMT <> 100 and SUM_TRAN_AMT <> 50 and SUM_TRAN_AMT <> -100 and SUM_TRAN_AMT <> -50), SUM_TRAN_AMT,

if(TRAN_CD <> 355  and (DFNR_CD <> 5200 and DFNR_CD <> 52000 and DFNR_CD <> 25000 and DFNR_CD <> 50191), SUM_TRAN_AMT, 0)) as Charges

When the second if is commented out(see below the first conditional works, when it is uncommented it does not.  Any ideas on why?

if(TRAN_CD <> 355 and (DFNR_CD = 0 and SUM_TRAN_AMT <> 100 and SUM_TRAN_AMT <> 50 and SUM_TRAN_AMT <> -100 and SUM_TRAN_AMT <> -50), SUM_TRAN_AMT, 0) as Charges

5 Replies
swuehl
MVP
MVP

What do you exactely mean with 'not working correctly'? Can you post some sample lines of input data and what you expect to see?

qlikofba
Contributor II
Contributor II
Author

There are DFNR_CD of 0 that have SUM TRAN AMTS of 100 that are being displayed as a Charge of 100.

They should be displayed as 0

swuehl
MVP
MVP

What about the TRAN_CD of these records?

If TRAN_CD <> 355, wouldn't the second if() statement be valuated true?

qlikofba
Contributor II
Contributor II
Author

The tran codes that are 355 should be displayed as 0s as well.

swuehl
MVP
MVP

What exactely is wrong with the result?

LOAD

if(TRAN_CD <> 355 and (DFNR_CD = 0 and SUM_TRAN_AMT <> 100 and SUM_TRAN_AMT <> 50 and SUM_TRAN_AMT <> -100 and SUM_TRAN_AMT <> -50), SUM_TRAN_AMT,

if(TRAN_CD <> 355  and (DFNR_CD <> 5200 and DFNR_CD <> 52000 and DFNR_CD <> 25000 and DFNR_CD <> 50191), SUM_TRAN_AMT, 0)) as Charges,

*

INLINE [

TRAN_CD, DFNR_CD, SUM_TRAN_AMT

0, 0,100

355,0,100

];