Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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;
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.
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;
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
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
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;
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.