Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I need to create a script that clones table 2 with the result
cod | date | balance |
10 | 29/05/2024 | 10 |
10 | 30/05/2024 | 11 |
11 | 29/05/2024 | 9 |
11 | 30/05/2024 | 12 |
table 2
In example table 2 it generated records that are missing as of today.
cod | date | balance |
11 | 29/05/2024 | 9 |
11 | 30/05/2024 | 12 |
11 | 31/05/2024 | 12 |
11 | 01/06/2024 | 12 |
11 | 02/06/2024 | 12 |
11 | 03/06/2024 | 12 |
11 | 04/06/2024 | 12 |
10 | 29/05/2024 | 10 |
10 | 30/05/2024 | 11 |
10 | 31/05/2024 | 11 |
10 | 01/06/2024 | 11 |
10 | 02/06/2024 | 11 |
10 | 03/06/2024 | 11 |
10 | 04/06/2024 | 11 |
Imprtant that your table is read ordered by cod and date (desc).
from_to:
LOAD cod, date as valid_from, If(Peek('cod') = cod, Peek('valid_from')-1, today()) as valid_to, balance
RESIDENT Data
ORDER BY cod, date DESC;
Assuming you have a table containing all the "date" values you are interested in (if not then you will need to create it) .
Intervalmatch:
Intervalmatch (date)
LOAD valid_to, valid_from RESIDENT from_to;
You could try to generate a table with a to and from field. Like below.
Load cod, date as valid_from, peek(date) as valid_to, balance
From source
Order by cod, date desc;
Once you have this table the use interval match on the date field in a transaction table containing all dates or master calendar.
I haven't used qlik for a long time, can my friend create an example for me. thank you from the bottom of my heart🤔
Imprtant that your table is read ordered by cod and date (desc).
from_to:
LOAD cod, date as valid_from, If(Peek('cod') = cod, Peek('valid_from')-1, today()) as valid_to, balance
RESIDENT Data
ORDER BY cod, date DESC;
Assuming you have a table containing all the "date" values you are interested in (if not then you will need to create it) .
Intervalmatch:
Intervalmatch (date)
LOAD valid_to, valid_from RESIDENT from_to;
balance | cod | date | valid_from | valid_to |
10 | 10 | 29/05/2024 | 29/05/2024 | 29/05/2024 |
9 | 11 | 29/05/2024 | 29/05/2024 | 29/05/2024 |
11 | 10 | 30/05/2024 | 30/05/2024 | 05/06/2024 |
12 | 11 | 30/05/2024 | 30/05/2024 | 05/06/2024 |
The logic was correct, but I would like to clone if there was no record in the current month. There's a way my friend can see if he can do it for me.
balance | cod | date |
10 | 10 | 29/05/2024 |
9 | 11 | 29/05/2024 |
11 | 10 | 30/05/2024 |
12 | 11 | 30/05/2024 |
11 | 10 | 05/06/2024 |
12 | 11 | 05/06/2024 |