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: 
cristianj23a
Partner - Creator III
Partner - Creator III

Count days ago selecting a day qlikview.

Hi Guys.

Is it possible to count days ago when I select a day? Example.

Mainly the absences of a person who is registered daily is displayed.

Captura.PNG

Now when I select a day, it only shows me one row and one day in the text object.

Captura.PNG

The objective is to obtain the elapsed days, for example in the image it is visualized that 7 days elapsed.

That value should be in the text object.

Greetings.

Atachement the Qvw.

https://www.linkedin.com/in/cristianjorge/
Do not forget to mark as "Accepted Solution" the comment that resolves the doubt.
1 Solution

Accepted Solutions
diego_a_barboza
Creator
Creator

Mirá este ejemplo y decime si te sirve: Se pueden ver las ausencias acumuladas y las consecutivas (ambos campos son calculados en el script), eso te va a permitir armar un set analysis a tu gusto:

Acumulados.jpg

Adjunto te mando el qvw con el script: es el que vos subiste, pero modificado y haciendo un binary load al original. Lo mas importante es que los campos de ID de empleado, fecha y el flag de ausencia deben estar en la misma tabla, para facilitar los cálculos.

Saludos.

View solution in original post

6 Replies
diego_a_barboza
Creator
Creator

You have two options:

  • Fast and Easy: Create a paralel calendar table and that would be the one you would use for the date selection. This paralel calendar shall not be connected to the main data model: instead, you create a set analysis that only get the dates that are minor or equal ( <= ) to the date field in the paralel calendar. This set analysis should be present in any object that requires this data to be filtered.
  • Slow and Solid: Create a second calendar table that is connected to your data model via interval match: the start date would be the same (the first date of data... or it also could be the first day of the year) and the end date for the interval would be the date that would be selected on the calendar. The main advantage of this solution is that is more performant, however it may require a lot of changes on the current script of your application apart from that, you would not be required to write down the same set analysis over and over again.

Please, let me know if you require further help on this.
Regards.

cristianj23a
Partner - Creator III
Partner - Creator III
Author

Hola diego, hablas español?

La segunda opcion se ve viable, pero como contaría el rango de días?.El conteo tiene que ser dinámico porque cuando la persona falta mas de cuatro días, tiene que desaparecer de la tabla.

https://www.linkedin.com/in/cristianjorge/
Do not forget to mark as "Accepted Solution" the comment that resolves the doubt.
diego_a_barboza
Creator
Creator

Hola, me puse a pensar un poco: si creas campos que cuenten acumulados y/o

consecutivos desde el script es bastante fácil. Supongamos:

Ausencias_data: load * inline [

Día, ausencia,empleado

1, 1,a

2, 1,a

3, 0,a

4, 1,a

5, 1,a

1, 0,b];

Esto lo logras de la siguiente manera:

1- ordena los datos por empleado y días (en ese orden)

2- incluí un flag de ausencia (creo que es el que usas de contador ahora)

3- recarga la tabla con resident e incluí los siguientes campos calculados:

Left join Ausencias_data load

If(rownum() = 1 or empleado <> previous(empleado),

ausencia,

if(ausencia > 0 and empleado = previous(empleado),

previous(consecutiva)+1,0)) as consecutiva,

If(rownum() = 1 or empleado <> previous(empleado),

ausencia,

If(ausencia > 0 and empleado = previous(empleado) ,

previous(acumulada)+1,

previous(acumulada))) as acumulada

Resident Ausencias_data;

Creo que está solución es más facil, ya que usas un calendario común y al

seleccionar un día te muestra lo que necesitas ver. Revisa el código,

porque estoy en el colectivo y me debo de haber olvidado una coma o un

paréntesis por ahí.

Saludos

El 25 ene. 2018 17:51, "Cristian Jorge" <qcwebmaster@qlikview.com> escribió:

Qlik Community <https://community.qlik.com/?et=watches.email.thread>

Count days ago selecting a day qlikview.

reply from Cristian Jorge

<https://community.qlik.com/people/cristianjmr?et=watches.email.thread> in *New

to QlikView* - View the full discussion

<https://community.qlik.com/message/1424447?et=watches.email.thread#1424447>

cristianj23a
Partner - Creator III
Partner - Creator III
Author

Sobre el calendario, realmente viene de un infotipo de SAP que desglose día por día para relacionar las fechas con otras tablas.

Sobre la sentencia rownum no existe en qlik, que sentencia seria.

Hay dos campos que no reconozco Sentencia y Acumulada, donde crearía esos campos?

Gracias por la ayuda diego.

Saludos.

https://www.linkedin.com/in/cristianjorge/
Do not forget to mark as "Accepted Solution" the comment that resolves the doubt.
diego_a_barboza
Creator
Creator

Mirá este ejemplo y decime si te sirve: Se pueden ver las ausencias acumuladas y las consecutivas (ambos campos son calculados en el script), eso te va a permitir armar un set analysis a tu gusto:

Acumulados.jpg

Adjunto te mando el qvw con el script: es el que vos subiste, pero modificado y haciendo un binary load al original. Lo mas importante es que los campos de ID de empleado, fecha y el flag de ausencia deben estar en la misma tabla, para facilitar los cálculos.

Saludos.

cristianj23a
Partner - Creator III
Partner - Creator III
Author

Exacto, eso es lo que buscaba.

Muchas gracias diego.

Saludos.

https://www.linkedin.com/in/cristianjorge/
Do not forget to mark as "Accepted Solution" the comment that resolves the doubt.