Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
martyn_birzys
Creator
Creator

Why column5 does not equal column3 using Peek()?

I am trying to pass variable from either column3 or column4 to a column5 on the same row, depending on condition. But the result does not correspond the row.

I am aware that Peek() evaluates by load order - but dos it not stay on the same row in a line of script?

table1:

LOAD * INLINE [ 

Country, Continent, Heat, Rain 

Argentina, South America, Mild, Rainy 

Mexico, North America, Hot, Dry 

Sweden, North Europe, Cold, Snow 

Cyprus, South Europe, Hot, Humid ];

table2:

LOAD *,

If(Left(Continent,5) like '*North*',Peek('Heat'),Peek('Rain')) as Climate

Resident table1;

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Well, probably because column1 contains country names and column3 contains a temperature indication. And the peek function looks at the previous row of the target table. So, no it does not stay on the same row. That's why it's called in inter record function. Perhaps you want this instead:

LOAD *, If(Left(Continent,5) = 'North',Heat,Rain) as Climate

Resident table1;


talk is cheap, supply exceeds demand
martyn_birzys
Creator
Creator
Author

Apologies, I have corrected the column numbers. I am looking to pass value from either column3 or column4 to column5.

I see your point - I don't need to use Peek() at all.

Is it possible to peek to the same row without for loop?