Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
alelopezp
Contributor II
Contributor II

Date range from last year with setAnalysis

Hi! I have been having some trouble with a date range for QlikView. I already have a date range selector that works great, but when it's the time for using setAnalysis and get the same range in the prior year I just can't make it when using the selector.

I mean, this works when I use the list boxes of my mastercalendar but not for my date picker ranges

Anio = Year and PrimaNeta_EQ = Sales

Sum({$<Anio={$(=Anio-1)}>}PrimaNeta_EQ)

I left you here the thing I'm working on, so you can better idea of the problem.

Thanks for reading!

1 Solution

Accepted Solutions
CarlosAMonroy
Creator III
Creator III

Alejandra, la expresion que puse le faltaban 2 parentesis (No se copio con el formato correcto).

La expresion funciona bien. Ten en cuenta que si estas seleccionando el anio actual, y en el set analysis quieres mostrar para el anio anterior, entonces falta excluir las selecciones para que muestre los datos correctos.

Esta expresion funciona en tu dashboard:

Sum(

{$<Anio=, Date_1=,  Date_1={">=$(=Date(AddMonths(Min(Date_1),-12),'DD-MM-YYYY')) <=$(=Date(AddMonths(Max(Date_1),-12),'DD-MM-YYYY'))"}>}

PrimaNeta_EQ)


Carlos M

View solution in original post

6 Replies
dplr-rn
Partner - Master III
Partner - Master III

the expression works in your data model. see below i changed last year expression to yours Sum({$<Anio={$(=Anio-1)}>}PrimaNeta_EQ) 

i am not clear on the issue

Capture.PNG

alelopezp
Contributor II
Contributor II
Author

Hi!

If you use the date pickers for example, from 17/04/2018 to 5/05/2018 it takes the selection of that range, but I also need the same range from last year selection, in other words, the sales from 17/04/2017 to 5/05/2017.

If i use the listboxes to pick full months I have no problem, the problem comes when I select a date range with the selectors.

CarlosAMonroy
Creator III
Creator III

Hola Alejandra,

Puedes usar el siguiente set analysis. No abri tu archivo, pero por lo que lei, buscas tener la misma expresion del anio actual para el anio anterior basado en tus selecciones, cierto?

Hay distintas formas de obtener el resultado que deseas, una de ellas es la siguiente:

Sum({$<Campo_Fecha={">=$(=AddMonths(Min(Campo_Fecha),-12 <=$(=AddMonths(Max(Campo_Fecha),-12))"}>} PrimaNeta_EQ)


En lugar de usar el campo anio, utiliza tu campo que tenga la fecha completa.


Espero te sirva,

Carlos M

alelopezp
Contributor II
Contributor II
Author

Hola Carlos, ya probé el código que me compartiste, pero no obtuve resultados. La suma me dio 0.

CarlosAMonroy
Creator III
Creator III

Alejandra, la expresion que puse le faltaban 2 parentesis (No se copio con el formato correcto).

La expresion funciona bien. Ten en cuenta que si estas seleccionando el anio actual, y en el set analysis quieres mostrar para el anio anterior, entonces falta excluir las selecciones para que muestre los datos correctos.

Esta expresion funciona en tu dashboard:

Sum(

{$<Anio=, Date_1=,  Date_1={">=$(=Date(AddMonths(Min(Date_1),-12),'DD-MM-YYYY')) <=$(=Date(AddMonths(Max(Date_1),-12),'DD-MM-YYYY'))"}>}

PrimaNeta_EQ)


Carlos M

alelopezp
Contributor II
Contributor II
Author

Ya la probé y funcionó a la perfección, Muchísimas gracias Carlos!