Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
karelibarcar
Contributor III
Contributor III

Optimize an advanced expression

Hello World,

Please, Can you tell me how I can optimize the expression bellow?

if(Identificador_Cuenta = 'Deudora',

if (Acumula_Saldo = {'1'},

Sum({<Mes =, Año = , Identificador_Mes = {'<=$(#=vMesActual)'}, Tipo_Cuenta = {'D'}>}Valor_Cuenta)

- Sum({<Mes =, Año = , Identificador_Mes = {'<=$(#=vMesActual)'}, Tipo_Cuenta = {'C'}>}Valor_Cuenta)

,

Sum({<Mes =, Identificador_Mes = {'<=$(#=vMesActual)'}, Tipo_Cuenta = {'D'}>}Valor_Cuenta)

- Sum({<Mes =, Identificador_Mes = {'<=$(#=vMesActual)'}, Tipo_Cuenta = {'C'}>}Valor_Cuenta)

)

,

if (Acumula_Saldo = {'1'},

Sum({<Mes =, Año = , Identificador_Mes = {'<=$(#=vMesActual)'}, Tipo_Cuenta = {'C'}>}Valor_Cuenta)

- Sum({<Mes =, Año = , Identificador_Mes = {'<=$(#=vMesActual)'}, Tipo_Cuenta = {'D'}>}Valor_Cuenta)

,

Sum({<Mes =, Identificador_Mes = {'<=$(#=vMesActual)'}, Tipo_Cuenta = {'C'}>}Valor_Cuenta)

- Sum({<Mes =, Identificador_Mes = {'<=$(#=vMesActual)'}, Tipo_Cuenta = {'D'}>}Valor_Cuenta)

)

)

The differences are in red.

1 Reply
neoshantanu08
Contributor
Contributor

Can you create 2 variables for:

Tipo_Cuenta and Año as:

vTipo and vAño

Provide them values as 'C'/'D' and */$ based on value for the 2 fields:

'Identificador_Cuenta' and 'Acumula_Saldo'

Hence there won't be any need to use If with set analysis statements