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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis and variables

Hi, im trying to build an expression with a variable but is not working.

The expression is:

=sum({<idFechaReserva={"<=$(=vIdFechaComparativa)"}>}MontoPagado).

The strange thing is that when i try with 

=sum({<idFechaReserva={"<=20131010"}>}MontoPagado)

its works, and the variable vIdFechaComparativa is difine like NUM(replace(date(vFechaComparativa,'YYYY-MM-DD'),'-',''))

What im doing wrong?

Thanks,

1 Solution

Accepted Solutions
Nicole-Smith

Try defining vldFechaComparativa as:

NUM(date($(vFechaComparativa),'YYYY-MM-DD'))

or

NUM(date#($(vFechaComparativa),'YYYY-MM-DD'))

And make your expression:

=sum({<idFechaReserva={"<=$(=$(vIdFechaComparativa))"}>}MontoPagado)

View solution in original post

5 Replies
Anonymous
Not applicable
Author

Try below as your variable instead.


dual(replace(date(vFechaComparativa,'YYYY-MM-DD'),'-',''),vFechaComparativa)


I believe the replace function defines the result as  text so >= would not work in your set analysis.

Nicole-Smith

Try defining vldFechaComparativa as:

NUM(date($(vFechaComparativa),'YYYY-MM-DD'))

or

NUM(date#($(vFechaComparativa),'YYYY-MM-DD'))

And make your expression:

=sum({<idFechaReserva={"<=$(=$(vIdFechaComparativa))"}>}MontoPagado)

whiteline
Master II
Master II

Hi.

I guess, it's all about dates.

This expression is strange:

=NUM(replace(date(vFechaComparativa,'YYYY-MM-DD'),'-',''))

First, you change text date format to 'YYYY-MM-DD' then manually remove '-' and get text YYYYMMDD.

After that you use a function that is supposed to change text format (of dual) to numeric. I guess it returns null.

You have to rewrite the expression to use numerical comparison in set analysis:

=sum({<idFechaReserva={"=idFechaReserva<=$(=vIdFechaComparativa)"}>}MontoPagado)

And variable =NUM(date#($(vFechaComparativa),'YYYY-MM-DD') ) assuming that  vFechaComparativa contains date as simple text.

Not applicable
Author

Hello Augusto,

Try this:

=sum({<idFechaReserva={"<='$(=Date(vIdFechaComparativa))' "}>}MontoPagado).


I have a similar case and made a simple example with this formula.


sum({<Fecha={'$(=Date(Max(Fecha)))'}>}Venta)


See attached document.

Best regards.


Y como veo que usas expresiones en español va una breve explicación en español... en el set analysis debemos poner entre comillas simples el valor de fecha pues sino no lo reconoce qlikview además de darle formato de fecha sino lo toma como numero y al intentar buscarlo dentro de nuestro campo Fecha se confunde. En el archivo adjunto esta la expresión que use y la deje sin etiqueta para que veas como interpreta el valor dentro del set analysis (Ver el titulo en el la cabecera de la expresión).


Saludos.

Not applicable
Author

Thanks!

The variable definition was correct, but the expression has to be

=sum({<idFechaReserva={"<=$(=$(vIdFechaComparativa))"}>}MontoPagado)