Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Recurrent Previous()?

Hi guys I am having a bit of a problem, I am trying to fill null rows by the last non null value. ill exemplify in a table.

This is what i have:

Ticket
Severity
status
date
AAA-01/01/2015 13:00
AAA-01/01/2015 14:10
AAASR01/01/2015 15:20
AAA-Actioned01/01/2015 16:00
AAA01/01/2015 17:00
AAASev101/01/2015 18:00
AAA--01/01/2015 19:00
BBB--02/01/2015 13:00
BBB-on Hold03/01/2015 13:00
BBB--04/01/2015 13:00
BBB--05/01/2015 13:00
BBBSev2Actioned06/01/2015 13:00
BBB--07/01/2015 13:00

And this is what i want to achieve:

Ticket
Severity
status
date
AAASRActioned01/01/2015 13:00
AAASRActioned01/01/2015 14:10
AAASRActioned01/01/2015 15:20
AAASev1Actioned01/01/2015 16:00
AAASev1on Hold01/01/2015 17:00
AAASev1on Hold01/01/2015 18:00
AAA--01/01/2015 19:00
BBBSev2on Hold02/01/2015 13:00
BBBSev2on Hold03/01/2015 13:00
BBBSev2Actioned04/01/2015 13:00
BBBSev2Actioned05/01/2015 13:00
BBBSev2Actioned06/01/2015 13:00
BBB--07/01/2015 13:00

As you can see I want to obtain the previous value for each Ticket except for the last entry on each ticket, the last entry I will use a single value stored in a different table that is joined to this one by the ticket field and contains only 1 row.

Can someone please help? I can do this with previous function by loading the data in descending way but this only fills one previous null value and does no work when there is 2 and 3 null rows.

Many Thanks

1 Solution

Accepted Solutions
maxgro
MVP
MVP

a:

LOAD

  Ticket,

    if(Severity='-' or len(trim(Severity))=0, null(), Severity) as Severity,

    if(status='-' or len(trim(status))=0, null(), status) as status,

    date

FROM

[https://community.qlik.com/thread/172087]

(html, codepage is 1252, embedded labels, table is @1);

b:

NoConcatenate load

  Ticket, 

    date, 

  if(len(trim(Severity))=0 and Ticket=peek(Ticket), peek(Severity), Severity) as Severity,

  if(len(trim(status))=0 and Ticket=peek(Ticket), peek(status), status) as status

Resident a

Order By Ticket, date desc;

drop table a;

1.png

View solution in original post

3 Replies
hic
Former Employee
Former Employee

You're on the right track. Load the data descending as you suggest, and use Peek() instead of Previous(). Example:

     If( Len(Trim(Severity))=0, Peek(Severity), Severity) as Severity

HIC

maxgro
MVP
MVP

a:

LOAD

  Ticket,

    if(Severity='-' or len(trim(Severity))=0, null(), Severity) as Severity,

    if(status='-' or len(trim(status))=0, null(), status) as status,

    date

FROM

[https://community.qlik.com/thread/172087]

(html, codepage is 1252, embedded labels, table is @1);

b:

NoConcatenate load

  Ticket, 

    date, 

  if(len(trim(Severity))=0 and Ticket=peek(Ticket), peek(Severity), Severity) as Severity,

  if(len(trim(status))=0 and Ticket=peek(Ticket), peek(status), status) as status

Resident a

Order By Ticket, date desc;

drop table a;

1.png

Not applicable
Author

Hi I have tried with peek this works only for the first empty row, the 2nd empty row does not get populated, also I have a condition which is "if(Ticket = previous(Ticket), ...." as it can only compare if the ticket is the same and this as obviously will leave my first row empty as the Ticket is not the same as the rpevious for the first record.

Many Thanks