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

Filling columns depending on criteria

Hello Guys,

i have this table:

ID_1ID_2DateName
Ix21000101.01.2021Jane McKenzie
Ix21000101.01.2021 
Ix31000102.01.2021 
Ix31000202.01.2021 
Ix31000302.01.2021Peter Smith
Ix31000302.01.2021 
Ix21000403.01.2021Max Miller
Ix21000403.01.2021 
Ix21000403.01.2021 

 

Now i want the column Name to be filled,...

....if value in column ID_1 is 'Ix2' and....

....if the field contents of columns ID_2 and Date occur more than once and a value is found in column Name, then the name should be entered wherever the criteria from column ID_2 and Date are the same....

The final result *bold* should look like this:

ID_1ID_2DateName
Ix21000101.01.2021Jane McKenzie
Ix21000101.01.2021Jane McKenzie
Ix31000102.01.2021 
Ix31000202.01.2021 
Ix31000302.01.2021Peter Smith
Ix31000302.01.2021 
Ix21000403.01.2021Max Miller
Ix21000403.01.2021Max Miller
Ix21000403.01.2021Max Miller

 

Do you have any ideas for the script?

Thanks !!

Labels (1)
1 Reply
stevejoyce
Specialist II
Specialist II

You can do do this using peek (with no parameter = last loaded record) and sorting of the table appropriately.  This way you can pull the previous row name and "fill" down:

 

source_data:
LOAD
*

from https://community.qlik.com/t5/New-to-Qlik-Sense/Filling-columns-depending-on-criteria/td-p/1837960
//https://community.qlik.com/t5/QlikView-App-Dev/PivotTable-Diagram-does-not-show-dimension-with-value...

(html, utf8, embedded labels, table is @1)
;

 

rename field Name to source_name;

data_fillname:
load *
,If(len(trim(source_name))=0 and ID_1 = 'Ix2', If((ID_1=peek(ID_1)) and (ID_2=peek(ID_2)) and (Date=peek(Date)), peek(Name)), source_name) as Name
resident source_data
order by Date asc, ID_2 asc, ID_1 asc
;

drop table source_data;
drop field source_name;

exit script;