Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Fill with last non null value during script load

Hi,

I've got the following situation where there's this table (blue-colored columns):

NOTE: The green colored column is NOT part of the input data, it should be the output of the process I'm trying to figure out.

ProductPeriodPriceDesired Output: Price Column
A2015-0122
A2015-022
A2015-032
A2015-0433
B2015-030
B2015-0422
B2015-052
B2015-062
C2015-010
C2015-020
C2015-0344
C2015-044

GOAL: What I want to achieve during the script load is to replicate the last non null price value in all the following null price fields  (that is unless there is a new price value).

An example of what the desired output should be is shown in the green column (Desired Output).

Thank you all in advance.

1 Solution

Accepted Solutions
maxgro
MVP
MVP

1.png


t:

LOAD Product,     Period,     Price

FROM

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

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

f:

load *,

if(len(trim(Price))=0 and Product=peek(Product), Peek(DesiredPrice), alt(Price,0)) as DesiredPrice

Resident t

order by Product, Period;

DROP Table t;

View solution in original post

4 Replies
maxgro
MVP
MVP

1.png


t:

LOAD Product,     Period,     Price

FROM

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

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

f:

load *,

if(len(trim(Price))=0 and Product=peek(Product), Peek(DesiredPrice), alt(Price,0)) as DesiredPrice

Resident t

order by Product, Period;

DROP Table t;

Not applicable
Author

Massimo, thanks for you reply.

The Desired Price Column is not included in the input data, it should be the result of the script calculations.

Sorry if it is not clear.

swuehl
MVP
MVP

Massimo is not using the Desired Price Column when loading your sample table (loaded from this web page), but creating this column in his f table script.

Isn't this fulfilling your requirements?

Not applicable
Author

Oh, my bad. It does.

Thank you all.