Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

adnan_rafiq
Contributor II

Repeating values until null.

Hi everyone.

Just wanted to pick the brains of the gurus of QV. I want to repeat a value in a column that I get in a table using script, as many times until I find a non-null value in the same a column. So for example sake consider (AS-is)

Header 1Header 2
42186AB
CD
WE
TT
RR
QS
EF
42155GH
IJ
KL
SA
AS
QW
MN

I am trying to get, (To Be)

Header 1Header 2
42186AB
42186CD
42186WE
42186TT
42186RR
42186QS
42155GH
42155IJ
42155KL
42155SA
42155
42155

I have tried ALT, PEEK and PREVIOUS but only got values to repeat twice by using PREVIOUS.

Please help

1 Solution

Accepted Solutions

Re: Repeating values until null.

LOAD if(len(trim([Report number]))=0,Peek([Report number]),[Report number]) as Peekedcolumn,

    Column,

    Numbers

FROM

...

You're peeking in the wrong field. Use peek(Peekedcolumn) or give the resulting field the name [Report number]


talk is cheap, supply exceeds demand
18 Replies

Re: Repeating values until null.

LOAD

     If(Len(Trim([Header 1]))>0,[Header 1], Peek([Header 1]) as [Header 1],

     [Header 2]

FROM

     ...

If [Header 1] contains only numbers you could also try Alt([Header 1], peek([Header 1])) as [Header 1]


talk is cheap, supply exceeds demand

Re: Repeating values until null.

You can use fill option in Transformation Wizard.

LOAD [Header 1],

     [Header 2]

FROM

[Sample.xlsx]

(ooxml, embedded labels, table is Sheet1, filters(

Replace(1, top, StrCnd(null))

));

adnan_rafiq
Contributor II

Re: Repeating values until null.

Same result that I had already had the values repeat 1 time and then stop. see here

result.png

Re: Repeating values until null.

Post your qlikview document and source file.


talk is cheap, supply exceeds demand
Highlighted

Re: Repeating values until null.

try this


Load *,

         if( len(trim(Header1))=0, peek('Header1_1'),Header1) as Header1_1

FROm Table

adnan_rafiq
Contributor II

Re: Repeating values until null.

I want to do it via script.

adnan_rafiq
Contributor II

Re: Repeating values until null.

see reply above

Re: Repeating values until null.

The above code is load script.!!

Re: Repeating values until null.

what reply?

Community Browser