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

Current vs Previous calculation by Date

Hello,

i want to simulate the following table in QlikSense

2022 AMT 2022 2021 AMT 2021
01/11/2022 59.047 02/11/2021 0
02/11/2022 68.525 03/11/2021 0
03/11/2022 64.932 04/11/2021 0
04/11/2022 64.515 05/11/2021 0
05/11/2022 54.750 06/11/2021 0
07/11/2022 70.280 08/11/2021 0
08/11/2022 64.952 09/11/2021 0
09/11/2022 57.875 10/11/2021 0
10/11/2022 51.512 11/11/2021 0
11/11/2022 54.736 12/11/2021 0
12/11/2022 42.609 13/11/2021 0
13/11/2022 3.726 14/11/2021 0
14/11/2022 59.381 15/11/2021 0
15/11/2022 54.818 16/11/2021 0
16/11/2022 53.809 17/11/2021 0
17/11/2022 50.098 18/11/2021 0
18/11/2022 43.913 19/11/2021 0
19/11/2022 54.818 20/11/2021 0
20/11/2022 5.724 21/11/2021 0
21/11/2022 57.042 22/11/2021 0
22/11/2022 55.196 23/11/2021 0
23/11/2022 51.080 24/11/2021 0
24/11/2022 54.214 25/11/2021 0
25/11/2022 49.940 26/11/2021 0
26/11/2022 38.207 27/11/2021 0
27/11/2022 8.348 28/11/2021 0
28/11/2022 59.549 29/11/2021 0
29/11/2022 62.654 30/11/2021 0
30/11/2022 55.348 01/12/2021 0

 

The first column i have the calculated dimension =if([YEAR] = $(=max([YEAR])), [DATE])

The second column i have the measure sum({<[YEAR]={ $(=max([YEAR]))}>} SALES)

The third column i have the calculated dimension =if([YEAR] = $(=max([YEAR])), date(DATE]-364,'DD/MM/YYYY'))

My question is with which measure can i calculate the fourth column with the SALES of the third dimension ?

Has anyone an idea to help me ?

Thank you in advance.

Labels (1)
1 Reply
zar
Employee
Employee

Hi!

First of all, you can not have in the same table 1 column with todays dates, and values of toadies days, and other column with last year dates and values of last dates because Qlik is evaluating each row (unless you go through unneeded complex logic).

The measure you are looking for is:

Sum({<[Year]={$(=max([Year])-1)}, DateNum={">=$(=Max(DateNum)-364)"}>} 1)

But, it will be 0 in all Max Year rows:

zar_0-1674391926034.png