Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
ruben_moya
Creator
Creator

IF condition not workining properly app/script

Dear experts,

I'm having issues trying to find out why a simple if clause is not working.

This is the scenario:

Providers:
LOAD
if(ID_TipoRecurso_C= 'IMS', ID, ID_Long) as Provider_Key
,[ID]
,[ID_Long]
,[ID_TipoRecurso_C]
;
sql SELECT  ID
, ID_Long
,[ID_TipoRecurso_C]
FROM XXXXXXXXXXXXXXXX;

ruben_moya_0-1673598876486.png

I need to create a field that shows ID when the value for ID_TipoRecurso_C= 'IMS'.

I'vve confirmed that thee value in ID_TipoRecurso_C is actually 'IMS' 

I've also tried to add the condition with a case in the sql part. ACTUALLY, WHEN I TRY THE QUERY DIRECTLY ON MY DATABASE IT WORKS PROPERLY.

Do you guys know what could  be the problem here, it is quite a simple condition and it should be working correctly.

 

Thanks in advance.

 

Labels (1)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

force as text

 

Providers:
LOAD
if(ID_TipoRecurso_C= 'IMS', TEXT(ID), TEXT(ID_Long)) as Provider_Key
,[ID]
,[ID_Long]
,[ID_TipoRecurso_C]
;
sql SELECT 
CAST([ID] as TEXT) as [ID]         // as TEXT  or as varchar)
,CAST([ID_Long] as TEXT) as [ID_Long]
,[ID_TipoRecurso_C]
FROM XXXXXXXXXXXXXXXX;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

4 Replies
vinieme12
Champion III
Champion III

use Wildmatch() instead as it is case insensitive

if(Wildmatch(TRIM(ID_TipoRecurso_C,'IMS'), ID, ID_Long) as Provider_Key

 

or Index() to match avoiding  garbage characters if any

if(index(UPPER(ID_TipoRecurso_C),'IMS'),ID, ID_Long) as Provider_Key

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
ruben_moya
Creator
Creator
Author

Thanks @vinieme12 ,

I've tried your suggestions but both gave me the same result. Actually, in the example that I posted I had already checked that with the column '=if(ID_TipoRecurso_C= 'IMS', 'OK', 'KO')'  and it proofs that the string 'IMS' is corrrect

vinieme12
Champion III
Champion III

force as text

 

Providers:
LOAD
if(ID_TipoRecurso_C= 'IMS', TEXT(ID), TEXT(ID_Long)) as Provider_Key
,[ID]
,[ID_Long]
,[ID_TipoRecurso_C]
;
sql SELECT 
CAST([ID] as TEXT) as [ID]         // as TEXT  or as varchar)
,CAST([ID_Long] as TEXT) as [ID_Long]
,[ID_TipoRecurso_C]
FROM XXXXXXXXXXXXXXXX;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
ruben_moya
Creator
Creator
Author

Hi @vinieme12 , thanks a lot, it worked! Could you explain me why to understand the logic behind?

I realised that if i filtered the load to have just registers with ,[ID_TipoRecurso_C] ='IMS' the condition works.

Thanks a lot.