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

Filling missing fields with data depending on Date

Hi all!

I've got a problem and don't know how to solve it.

May be someone has an idea...

I've got a table:

NumberProcessDateStartDateEndTransactionDateTransactionNumber
111Process101.06.201709.06.201702.06.2017F1

111

03.06.2017F2
11110.06.2017F3
111Process211.06.201715.06.201712.06.2017F4
222Process309.06.201715.06.201710.06.2017F5
22212.06.2017F6

I need to fill fields: process, DateStart, DateEnd depending on TransactionDate

If TransactionDate fits between DateStart and DateEnd, fields should be filled, if not, not filled.

Final table should be like:

NumberProcessDateStartDateEndTransactionDateTransactionNumber
111Process101.06.201709.06.201702.06.2017F1
111Process101.06.201709.06.201703.06.2017

F2

111---10.06.2017F3
111Process211.06.201715.06.201712.06.2017F4
222Process309.06.201715.06.201710.06.2017F5
222Process309.06.201715.06.201712.06.2017F6

Thanks in advance!

2 Replies
antoniotiman
Master III
Master III

Hi Eugeniya,

LOAD Number,
If(Len(Trim(DateStart)) > 0 and Len(Trim(DateEnd)) > 0,
If(TransactionDate >= DateStart and TransactionDate <= DateEnd,Process),
If(TransactionDate >= Previous(DateStart) and TransactionDate <= Previous(DateEnd),Peek(Process))) as Process,
If(Len(Trim(DateStart)) > 0 and Len(Trim(DateEnd)) > 0,
If(TransactionDate >= DateStart and TransactionDate <= DateEnd,DateStart),
If(TransactionDate >= Previous(DateStart) and TransactionDate <= Previous(DateEnd),Peek(DateStart))) as DateStart,
If(Len(Trim(DateStart)) > 0 and Len(Trim(DateEnd)) > 0,
If(TransactionDate >= DateStart and TransactionDate <= DateEnd,DateEnd),
If(TransactionDate >= Previous(DateStart) and TransactionDate <= Previous(DateEnd),Peek(DateEnd))) as DateEnd,
TransactionDate,
TransactionNumber
FROM
"https://community.qlik.com/message/1311319"
(html, codepage is 1252, embedded labels, table is @1);

Regards,

Antonio

qliksus
Specialist II
Specialist II

Use the data transforamtion in the file wizard to fill the blank values with the previous row and then using the flag created below you can update to all fields

Data:
load *
Where flag=1;
LOAD Number,
Process,
DateStart,
DateEnd,
TransactionDate,
if( TransactionDate>=DateStart and TransactionDate<=DateEnd , 1,2) as flag,
TransactionNumber
FROM
Filldata.xlsx
(
ooxml, embedded labels, table is Sheet1, filters(
Replace(2, top, StrCnd(null)),
Replace(3, top, StrCnd(null)),
Replace(4, top, StrCnd(null))
));

load *
Where flag=2;
LOAD Number,
''
as Process,
''
as DateStart,
''
as DateEnd,
TransactionDate,
if( TransactionDate>=DateStart and TransactionDate<=DateEnd , 1,2) as flag,
TransactionNumber
FROM
Filldata.xlsx
(
ooxml, embedded labels, table is Sheet1, filters(
Replace(2, top, StrCnd(null)),
Replace(3, top, StrCnd(null)),
Replace(4, top, StrCnd(null))
));