Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Fill a field when empty with previous value

Hi

I have a table like this:

Field1,     Field2

1,               A

2,              

3,              

4,               B

5,              


So field2 is empty in rows 2,3 and 5.

I wish to get a field3 where if row in field2 is empty it takes the value before in field3, and if not it takes the value in field2, resulting this:

Field1,     Field2,     Field3

1,               A              A

2,                               A

3,                               A

4,               B              B

5,                               B


How can do it as easy as possible?


Thnaks

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like

LOAD Field1,

        If( Len(Trim(Field2)), Field2, Peek(Field3) ) as Field3

FROM YourTable;

View solution in original post

4 Replies
swuehl
MVP
MVP

Maybe like

LOAD Field1,

        If( Len(Trim(Field2)), Field2, Peek(Field3) ) as Field3

FROM YourTable;

Chanty4u
MVP
MVP

hi,wiz.PNG

sunny_talwar

Try this:

Table:

LOAD Field1,

  Field2,

  If(Len(Trim(Field2)) > 0, Field2, Peek('Field3')) as Field3;

LOAD * Inline [

Field1,     Field2

1,               A

2,             

3,             

4,               B

5,             

];


Capture.PNG