Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Mario3
Contributor
Contributor

Fill Average based on Previous and next Row

Dear Qlikers! 

I need to fill the data as below :
Input : 

Rec NoValueOutlier Flag
1320
2628.1671
331.26670

Output:

132
231.6335
331.2667

628.167 is an outlier in my data, I need to fill it with the average of the previous and the next row (using the script):

in this case (32+31.2667)/2 = 31.6335

Thank you in advance 
Mario

Labels (1)
4 Replies
Taoufiq_Zarra

@Mario3  only for this line ? (one line )

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Mario3
Contributor
Contributor
Author

No the whole data set. 
the outliers is flagged as "1" 
In case the previous and the next row of the outliers are not an outlier I need to apply this formula that I mentioned.

Appreciate your help! 

 

Mario3
Contributor
Contributor
Author

Hello @Taoufiq_Zarra  any idea how to solve this ? 

 

Frank_Hartmann
Master II
Master II

Maybe like this:

 

tmp:
load * Inline [
		RecNo,Value_,OutlierFlag
		1,32,0
		2,628.167,1
		3,31.2667,0 ];

final:
LOAD
  RecNo,	
  if(OutlierFlag=1,(PREVIOUS(Value_)+PEEK('Value_',RowNo(),'tmp'))/2,Value_) as Val,	
  OutlierFlag  
RESIDENT tmp;
DROP TABLE tmp;