
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Como evitar los if anidados muy largos
Estimados, una consulta:
¿Hay alguna forma de incluir en el script un campo que se construye con muchas condiciones, de una forma más sencilla, así como un "case"?
Necesito unir estas dos cadenas de sintaxis, pero aparte de largo, no me funciona bien:
if (IsNull(Cod_Ejecutivo), 'Sin ejecutivo',Cod_Ejecutivo) as Cod_Ejecutivo,
if (IsNull(Nombre_ejecutivo), 'Sin nombre',Nombre_ejecutivo) as Nombre_ejecutivo,
if (IsNull(Nombre_ejecutivo), 'Sin nombre', if(Mid(FACT,1,3)='002' and (CLASE_FACTURA='Zk06'), '200004656 - AUTOVENTA CUENCA', if(Mid(FACT,1,3)='003' and (CLASE_FACTURA='ZF06'), 'xxxxxxxxxx',
if(Mid(FACT,1,3)='004' and (CLASE_FACTURA='Zk06'), 'xxxxxxxxxx, if(Mid(FACT,1,3)='005' and (CLASE_FACTURA='Zk06'), 'xxxxxxxxxx',
Cod_Ejecutivo &' - '& Nombre_ejecutivo))))) as Nombre_ejecutivo_AUTO,
y
// if((Cod_cliente='A' or 'B' or 'C') and Mid(FACT_SRI,1,3)='002','xxxxxxxxxx',
// if((Cod_cliente='A' or 'B' or 'C') and Mid(FACT_SRI,1,3)='003','xxxxxxxxxx',
// if((Cod_cliente='A' or 'B' or 'C') and Mid(FACT_SRI,1,3)='004','xxxxxxxxxx',
// if((Cod_cliente='A' or 'B' or 'C') and Mid(FACT_SRI,1,3)='005','xxxxxxxxxx,Cod_Ejecutivo &' - '& Nombre_ejecutivo)))) AS Nombre_ejecutivo_AUTO,


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @sonicarm22 ,
I am not sure if my translation is correct.
I understand that you want to replace multiple IF -statement by something simple like "Case"
Did you test the " Switch..case..default..end" control statement? See https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlS...
Regards,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Toys R Us Credit Card wrote:
Estimados, una consulta:
¿Hay alguna forma de incluir en el script un campo que se construye con muchas condiciones, de una forma más sencilla, así como un "case"?
Necesito unir estas dos cadenas de sintaxis, pero aparte de largo, no me funciona bien:
if (IsNull(Cod_Ejecutivo), 'Sin ejecutivo',Cod_Ejecutivo) as Cod_Ejecutivo,
if (IsNull(Nombre_ejecutivo), 'Sin nombre',Nombre_ejecutivo) as Nombre_ejecutivo,
if (IsNull(Nombre_ejecutivo), 'Sin nombre', if(Mid(FACT,1,3)='002' and (CLASE_FACTURA='Zk06'), '200004656 - AUTOVENTA CUENCA', if(Mid(FACT,1,3)='003' and (CLASE_FACTURA='ZF06'), 'xxxxxxxxxx',
if(Mid(FACT,1,3)='004' and (CLASE_FACTURA='Zk06'), 'xxxxxxxxxx, if(Mid(FACT,1,3)='005' and (CLASE_FACTURA='Zk06'), 'xxxxxxxxxx',
Cod_Ejecutivo &' - '& Nombre_ejecutivo))))) as Nombre_ejecutivo_AUTO,
y
// if((Cod_cliente='A' or 'B' or 'C') and Mid(FACT_SRI,1,3)='002','xxxxxxxxxx',
// if((Cod_cliente='A' or 'B' or 'C') and Mid(FACT_SRI,1,3)='003','xxxxxxxxxx',
// if((Cod_cliente='A' or 'B' or 'C') and Mid(FACT_SRI,1,3)='004','xxxxxxxxxx',
// if((Cod_cliente='A' or 'B' or 'C') and Mid(FACT_SRI,1,3)='005','xxxxxxxxxx,Cod_Ejecutivo &' - '& Nombre_ejecutivo)))) AS Nombre_ejecutivo_AUTO,
El problema es que una instrucción if anidada comienza en la condición falsa de la primera instrucción if. Por el momento tienes 'Boston 15' en condición falsa. Entonces, si el valor no está en la primera lista, reemplácelo con 'Boston 15'. Ese es el final de la condición. Si puede explicar lo que está tratando de lograr, creo que podemos ayudarlo con la sintaxis.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you.
I will try.
