What is the dynamic solution to a linear interpolation of data in a row with missing values with an indefinite number of missing value sequences?

点点圈 提交于 2019-12-13 08:05:40

问题


I have this data

Date        Data
8/25/2017   980
8/24/2017   64
8/23/2017   593   
8/22/2017   595
8/21/2017   
8/20/2017   
8/19/2017   794
8/18/2017   437
8/17/2017   
8/16/2017   
8/15/2017   
8/14/2017   629

What if i wanted (794-595)/3 in cell 21st August and 2*(794-595)/3 in cell 22nd August and similarly (629-437)/4 in 17th August, 2*(629-437)/4 in 16th August etc...

And there are only 2 missing sequences of data in the entire data set. But i want to be able to do all this without knowing the number of missing sequences in advance.

How to do this dynamically without regard to the number of missing values in between?


回答1:


For a formula route you will need a helper column:

In row 2 of that helper column put:

=IF(B2="",INDEX(B:B,MATCH(1E+99,$B$1:B1))+((ROW() - MATCH(1E+99,$B$1:B1))*(INDEX(B2:INDEX(B:B,MATCH(1E+99,B:B)),MATCH(TRUE,INDEX((B2:INDEX(B:B,MATCH(1E+99,B:B))<>""),),0))-INDEX(B:B,MATCH(1E+99,$B$1:B1)))/(MATCH(TRUE,INDEX((B2:INDEX(B:B,MATCH(1E+99,B:B))<>""),),0)+ROW()-1-MATCH(1E+99,$B$1:B1))),B2)

And copy down the range

Then if you want you can copy and paste the values back over the original data.



来源:https://stackoverflow.com/questions/46202683/what-is-the-dynamic-solution-to-a-linear-interpolation-of-data-in-a-row-with-mis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!