Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Perus_Pena
Contributor III
Contributor III

Using Peek() to fill empty rows - but how can I limit it to matching ID?

Hello,

I can't figure out how to limit this to only for for same ID. Currently my issue is that this peeks from previous ID untill the correct ID has it's first value. I also have calendar here so the first value does not appear on the first date for that ID.

Final:

NoConcatenate

Load

ID,

date,

If(Len(Trim(status)) = 0, Peek('status'), status) as status

Resident Temp

order by date, ID asc;

I tried a for loop but that seems overly complicated.

 

Cheers,

Pena

Labels (3)
1 Solution

Accepted Solutions
anushree1
Specialist II
Specialist II

Please try:

If(ID =peek(ID) and Len(Trim(status)) = 0, Peek('status'), status) as status

View solution in original post

5 Replies
anushree1
Specialist II
Specialist II

Please try:

If(ID =peek(ID) and Len(Trim(status)) = 0, Peek('status'), status) as status

Vegar
MVP
MVP

Try to use @anushree1 solution, but didn't the order of your order by like this.

Final:
NoConcatenate
Load
ID,
date,
If(ID =peek(ID) and Len(Trim(status)) = 0, Peek('status'), status) as status
Resident Temp
order by ID, date;
Perus_Pena
Contributor III
Contributor III
Author

This seems to work as it leaves the early calendar empty, but I still need to check things.

How does the peek(ID) and Peek('status') "Connect"? I mean how does the ID=Peek(ID) know that it should peek the same row that the later peek does?

anushree1
Specialist II
Specialist II

Hi ,

Peek works row by row ,so on each row it applies the peek which eventually leads to the right result and yes as mentioned by @Vegar  please order the data using order by clause for the rows to appear properly , also check https://help.qlik.com/en-US/sense/April2019/Subsystems/Hub/Content/Sense_Hub/Scripting/InterRecordFu...

for better understanding on peek function

Perus_Pena
Contributor III
Contributor III
Author

Thanks @Vegar  @anushree1 !