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: 
hufernandes
Contributor
Contributor

New field with last non null value.

On qlik sense, with the following table:
[TESTE]:
LOAD *,
If(len(trim("REF"))= 0 or "REF"='NULL' or "REF"='-', Null(), "REF" ) as "CONSUMO_T0";

LOAD *
Inline ["AM_SUBS", "REF"
202201,
202202,
202203, 7
202204,
202205,
202206, 12
202207,
202208, ]
;

How can I load a new field on script called "CONSUMO_REF" where its value should be the last not null loaded. The resulting table should be the following:

AM_SUBS CONSUMO_REF
202201  
202202  
202203 7
202204 7
202205 7
202206 12
202207 12
202208 12
Labels (1)
1 Solution

Accepted Solutions
brunobertels
Master
Master

hi try thiis 

 

[TESTE]:
LOAD *,
If(len(trim("REF"))= 0 or "REF"='NULL' or "REF"='-', Null(), "REF" ) as "CONSUMO_T0",


If(len(trim("REF"))> 0 ,"REF", peek(CONSUMO_REF) )as "CONSUMO_REF";

LOAD *
Inline ["AM_SUBS", "REF"
202201,
202202,
202203, 7
202204,
202205,
202206, 12
202207,
202208, ]
;

View solution in original post

1 Reply
brunobertels
Master
Master

hi try thiis 

 

[TESTE]:
LOAD *,
If(len(trim("REF"))= 0 or "REF"='NULL' or "REF"='-', Null(), "REF" ) as "CONSUMO_T0",


If(len(trim("REF"))> 0 ,"REF", peek(CONSUMO_REF) )as "CONSUMO_REF";

LOAD *
Inline ["AM_SUBS", "REF"
202201,
202202,
202203, 7
202204,
202205,
202206, 12
202207,
202208, ]
;