Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

aggr with two conditions

Hi everyone,

        i will be pleased if someone could help me with this expression:

sum(Aggr(if(count(DEAL_EXTERNALS.deal_externals_id) > 1 and USERS.user_created = Mes_AntAnterior,1,0),USERS.email))

up to here:

sum(Aggr(if(count(DEAL_EXTERNALS.deal_externals_id) > 1 ,1,0),USERS.email)) the values are ok but,

when i add the second condition "and USERS.user_created = Mes_AntAnterior" the values get wrong.

Below the definitions of both:

Mes_AntAnterior= month(addmonths(today(),-2)) & '-' & year(addmonths(today(),-2))

USERS.user_created = month(today()) & '-' & year(today())

workaround:

sum(Aggr(if(count(DEAL_EXTERNALS.deal_externals_id) > 1 and USERS.created >= Today()-60,1,0),USERS.email))

where USERS.created has this kind of format 40493, 40494, 40497.....

i think the problem is with the definitions of Mes_AntAnterior and USERS.user_created. How can i change this definitions to solve the issue.

thanks.

gerardo

9 Replies
cesaraccardi
Specialist
Specialist

Hi gerardo, you can change the variable type in Document Properties dialog => Number sheet.

Not applicable
Author

Hi Cesar,

       do you think because of that i couldn't compare this: USERS.user_created = Mes_AntAnterior?

thanks

Gerardo

cesaraccardi
Specialist
Specialist

I think its possible... try to put the variable in a text object to check if the format is different.

sebastiandperei
Specialist
Specialist

Hi Gerar!

Mes_AntAnterior es un campo o una variable?

Si es un campo y no está en la misma tabla que USERS.user_created muchas veces es causa de que un Sum(If... no funcione.

Si es una variable (cosa que creo que es lo más lógico que sea), usá $(Mes_AntAnterior) en lugar de Mes_AntAnterior.

Por otro lado, como más importante, es qué formato tienen cada uno. Cuando indicás las definiciones en tu consulta los dos dependen de Today(), ninguno de un dato de campo... Dónde los definís? en el script (con let??) o en el panel de variables?? Disculpá mi falta de comprensión.

Not applicable
Author

Hola Sebastian! gracias por la respuesta...

estoy definiendo Mes_AntAnterior en el script con let, no asi el USERS.user_created que es el dato de un campo.

Voy a probar lo que me decis a ver que onda....

saludos!

sebastiandperei
Specialist
Specialist

Entonces Mes_AntAnterior es una variable. Si hacés un cuadro de texto con =Mes_AntAnterior, qué te muestra?

Por otro lado, te recomiendo sum en lugar de count... va más rápido

sebastiandperei
Specialist
Specialist

Y? Funcionó?

Not applicable
Author

Hola Sebastian! Perdón por no contestar antes. No pude probarlo todavía, estoy con unos quilombos en el servidor de correo que no me deja avanzar con qlikview.

De: Sebastian Pereira

Enviado el: domingo, 20 de mayo de 2012 10:34 p.m.

Para: Pauza, Gerardo

Asunto: - Re: aggr with two conditions

QlikCommunity <http://community.qlik.com/index.jspa>

Re: aggr with two conditions

created by Sebastian Pereira <http://community.qlik.com/people/sebastiandpereira> in New to QlikView - View the full discussion <http://community.qlik.com/message/221057#221057

sebastiandperei
Specialist
Specialist

Cómo van esos temas Gerar?