Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Case statement Replacement

Hi,

In my application so many CASE statements have been used to extract the data from database at script level. But today I got requirement that need to replace CASE statements with qlikview functions. But I am not able to find that. Could you please some one help me?

EX:

CASE WHEN A.N_ACRONYM = B.N_ACRONYM THEN 0 ELSE A.EAD END as EAD_WA

CASE WHEN CLOSEOUT_AGREEMENT_NUMBER = '0' THEN A.EAD ELSE A.NET_EAD END AS EAD,
     A.EAD_M_UNCAPPED ,


     CASE WHEN CLOSEOUT_AGREEMENT_NUMBER = '0' THEN A.EAD_UK ELSE A.NET_EAD_UK END AS

CASE WHEN A.N_ACRONYM = B.N_ACRONYM THEN 0 ELSE A.PD_FLOOR END as PD_FLOOR_WA,
     CASE WHEN A.N_ACRONYM = B.N_ACRONYM THEN 0 ELSE A.EAD END as EAD_WA,
     CASE WHEN A.N_ACRONYM = B.N_ACRONYM THEN 0 ELSE A.LGD END as LGD_WA

CASE WHEN CLOSEOUT_AGREEMENT_NUMBER = '0' THEN A.EAD ELSE A.NET_EAD END AS EAD,
     A.EAD_M_UNCAPPED ,
     CASE WHEN CLOSEOUT_AGREEMENT_NUMBER = '0' THEN A.EAD_UK ELSE A.NET_EAD_UK END AS EAD_UK ,

Thank you


13 Replies
Not applicable
Author

Hi,

My data is from SYBASE- Database. So is IF statement will support at script

Thank you.

anbu1984
Master III
Master III

You can use If in the script as below

Load

If(N_ACRONYM_A = N_ACRONYM_B, 0, EAD ) As EAD_WA,

If(CLOSEOUT_AGREEMENT_NUMBER = '0',EAD,NET_EAD) As EAD;

Sql Select A.N_ACRONYM As N_ACRONYM_A,

B.N_ACRONYM As N_ACRONYM_B,

...

From ...

flipside
Partner - Specialist II
Partner - Specialist II

The IF statement being suggested here is being executed by the Qlikview engine because it is written in the 'preceding load' part of the script. It doesn't matter from which database the data comes.

When writing code that comes after the SQL SELECT part, this is executed by the database engine so needs to comply with the database query language AND also be supported by the driver being used to connect to the database.


Not applicable
Author

Thanks Anbu,

I could understand clearly and I made it at my work.

Thank you.