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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression Problem - Variable

Hello to all.

I'm implementing a new information in company's Qlikview app and for some reason i can't manage to make a certain expression to work... I have an expression just like this one:

MAX(IF(SSS_SEMANA_FILTRO = SEMANA_FILTRO AND SSS_SEMANA_GRIFFE = GRIFFE

            AND SSS_SEMANA_CODIGO_COLECAO = CODIGO_COLECAO, SSS_SEMANA_MAX_DATA_SEMANA))-365

Then, based on the above expression i created a variable containing it and i called it varVSSS, that's my variable's name. After that, i want to use the variable on an expression, such as this one...

SUM(IF(DATA_PRIMEIRA_VENDA <= $(varVSSS), VALOR_VENDA - VALOR_TROCA - DESCONTO_VENDA - DESCONTO_TROCA))

So, basically, based on a date comparison i want to make a SUM with some fields... the problem is.... when i add the variable to the expression, i get no result, nothing returns, but as a test, checking for the variable's value gives 41305 or 31/01/2013... and then if i put the return itself on the expression, such as:

SUM(IF(DATA_PRIMEIRA_VENDA <= 41305, VALOR_VENDA - VALOR_TROCA - DESCONTO_VENDA - DESCONTO_TROCA))

It works perfectly with the variable's value, but not with the variable itself... so... any guess ? am I doing something wrong ? Could not think about it;

Thanks in advance.

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I assume that the definition of your variable is a string:
MAX(IF(SSS_SEMANA_FILTRO = SEMANA_FILTRO AND SSS_SEMANA_GRIFFE = GRIFFE
            AND SSS_SEMANA_CODIGO_COLECAO = CODIGO_COLECAO, SSS_SEMANA_MAX_DATA_SEMANA))-365
without '=' sign
So, in your expression, you have aggregation within aggregation:
SUM(IF(DATA_PRIMEIRA_VENDA <= MAX(...), ...
and it is not allowed without aggr() function.

My guess is that you need just the result of that sum() in the variable.  To do this, add '=':
=MAX(IF(SSS_SEMANA_FILTRO = SEMANA_FILTRO AND SSS_SEMANA_GRIFFE = GRIFFE
            AND SSS_SEMANA_CODIGO_COLECAO = CODIGO_COLECAO, SSS_SEMANA_MAX_DATA_SEMANA))-365

Regards,
Michael

View solution in original post

1 Reply
Anonymous
Not applicable
Author

I assume that the definition of your variable is a string:
MAX(IF(SSS_SEMANA_FILTRO = SEMANA_FILTRO AND SSS_SEMANA_GRIFFE = GRIFFE
            AND SSS_SEMANA_CODIGO_COLECAO = CODIGO_COLECAO, SSS_SEMANA_MAX_DATA_SEMANA))-365
without '=' sign
So, in your expression, you have aggregation within aggregation:
SUM(IF(DATA_PRIMEIRA_VENDA <= MAX(...), ...
and it is not allowed without aggr() function.

My guess is that you need just the result of that sum() in the variable.  To do this, add '=':
=MAX(IF(SSS_SEMANA_FILTRO = SEMANA_FILTRO AND SSS_SEMANA_GRIFFE = GRIFFE
            AND SSS_SEMANA_CODIGO_COLECAO = CODIGO_COLECAO, SSS_SEMANA_MAX_DATA_SEMANA))-365

Regards,
Michael