Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculate Expression in straight table with 3 different calender fields

Hi, I have 3 calender fields. 2 of them from table "Calendario" and 1 from "DetalleVentas". (see image below) diagram1.PNG

As you can see primary key is "Fecha de Venta" and it's a Date type.

"Ventas del Dia" is in spanish so it's like saying "Sales per Day" in english and it is a Number type.

In design I have 3 calenders.

calendar.PNGThe blue should always be the current selection and is "Fecha de Venta".

The yellow is "Fecha Anterior Actual". This column should....let say search for "Fecha de Venta" inside "DetalleVentas" table and use the "Ventas del Dia". So when I use my expression, I can show all sales per day of "Fecha Anterior Actual" and not the selected "Fecha de Venta".

The orange is "Fecha Anterior Siguiente". Same concept... Need to search.

The straight table should show the following columns using "Ventas del Dia" that is a number type:

calendar columns.PNG

I can actually show as a label...but I' cant use "Ventas del Dia" in the column as numbers.

I appreciate your help! Thanks

3 Replies
Gysbert_Wassenaar

The blue should always be the current selection and is "Fecha de Venta".

The yellow is "Fecha Anterior Actual". This column should....let say search for "Fecha de Venta" inside "DetalleVentas" table and use the "Ventas del Dia".

If blue is the current selection then the table DetalleVentas is filtered on that value. If you want an additional filter on Fecha Anterior Actual then DetalleVentas will be filtered on Fecha de Venta and Fecha Anterior Actual. So going by your screenshot only the records that meet the condition (Fecha de Venta = 12/02/2015  AND Fecha Anterior Actual = 12/02/2014) will remain. If you then also want to filter on Fecha Anterior Siguiente then the only the records remain that meet the condition (Fecha de Venta = 12/02/2014  AND Fecha Anterior Actual = 12/02/2015 AND Fecha Anterior Siguiente = 13/02/2014). It's possible that no record exists in Calendrio with these values in these fields. In that case there are no associated records in DetalleVentas to calculate a result from.


talk is cheap, supply exceeds demand
david_paraje
Contributor II
Contributor II

Hola.

no me queda muy claro tu planteamiento pero te doy un par de pistas de lo que he entendido a ver si te vale.

Yo me creo casi siempre que trabajo con fechas una tabla de calendario, completa, de 1-1-año a 31-12-año de los años que quiera o necesito y esta tabla esta vinculada con la tabla de hechos que corresponda. En tu caso, la tabla de ventas.

Desde ese momento, tu puedes seleccionar cualquier fecha y si tiene ventas saldrá la información donde sea.

A partir de ahí viene la duda.

Si lo que quieres es un venta desde Fecha anterior, pasando por la fecha actual y/o hasta la fecha posterior yo utilizaría por ejemplo 2 variables para sacar los valores de fecha anterior y posterior. y utilizando operadores de conjuntos {<>} haría los "bloques" que necesitaras...


Not applicable
Author

Ok. I solved by myself the code in the expression.

Num(Sum({<[Fecha de Venta]= {'$(=[Fecha Anterior Siguiente])'}>} [Ventas del Dia]))

With this line I can now work all my data


Later on, I made this expression and it works!

Num(Sum({<[Fecha de Venta]= {'$(=Date([Fecha de Venta] - 1))'}>} [Promedio Anual del Dia])) + Num(Sum([Promedio Anual del Dia]))

Actually don't know how to explain what I did but I got the calculations I want
Thanks for the replys!