Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
abhijith28
Creator II
Creator II

Peek or Previous function if the value is null in Qliksense

Hi 

Can anyone help me with the below scenario.

There's a scenario below is the input table:

abhijith28_0-1616580254993.png

Expected output:

abhijith28_1-1616580281106.png

Calculation condition :  

For Name=B, ID=3, Value is null, as it is null it should take above value as Name and Cross values are same.

Similarly for Name=C, for ID=5,6,7 value is null, so copy the value from ID=4 and paste it in ID=5,6,7 (Name and Cross are same)

I tried using the below condition in load script but not able to return the expected output

if(Name=previous(Name) and Cross=previous(Cross) and len(Cross)>0,peek(Value),Value)) 

Please find the attached sample app

 

Thanks & Regards,

Abhijith

 

1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

Hi 

this script should do the trick for you

TableTemp:

Load * inline [

ID,	Name,	Cross,	Value,
1,	A,		
2,	B,	1,	25
3,	B,	1,	
4,	C,	1,	30
5,	C,	1,	
6,	C,	1,	
7,	C,	1,	
8,	D,	5,	35
9,	D,	5,	
10,	D,	

];


Table:
load ID,
     Name, 
     Cross,
     if(Previous(Name)=Name and Previous(Cross)=Cross and len(Cross)>0 and len(Value)<1,peek('NewValue'),Value) as NewValue
Resident TableTemp
order by ID;

drop table TableTemp;

rename field NewValue to Value;

View solution in original post

2 Replies
lironbaram
Partner - Master III
Partner - Master III

Hi 

this script should do the trick for you

TableTemp:

Load * inline [

ID,	Name,	Cross,	Value,
1,	A,		
2,	B,	1,	25
3,	B,	1,	
4,	C,	1,	30
5,	C,	1,	
6,	C,	1,	
7,	C,	1,	
8,	D,	5,	35
9,	D,	5,	
10,	D,	

];


Table:
load ID,
     Name, 
     Cross,
     if(Previous(Name)=Name and Previous(Cross)=Cross and len(Cross)>0 and len(Value)<1,peek('NewValue'),Value) as NewValue
Resident TableTemp
order by ID;

drop table TableTemp;

rename field NewValue to Value;
abhijith28
Creator II
Creator II
Author

Thanks @lironbaram