我对excel不了解,我想知道是否有一种方法可以使用excel公式将此qof编码中的asof join语句转换为一个
:update string issueSeries from aj[`sym`issueSeries`stockExchange`time;update `$issueSeries from table;update `g#sym from `time xasc select time+maxinterval,sym,`$issueSeries,stockExchange,refprice,refpricetime,prevpricetime,prevprice from reftable];
Table 1
Time Exc sym price
2:40:29 PM 25001 AMX 14.47
2:40:48 PM 25001 AMX 14.48
2:40:53 PM 25001 AMX 14.45
2:41:21 PM 25001 AMX 14.44
2:41:29 PM 25001 AMX 14.49
Table 2
Exc Sym Refprice ref-time
25001 AMX 14.47 2:39:54 PM
25001 AMX 14.46 2:40:36 PM
25001 AMX 14.46 2:41:19 PM
25001 AMX 14.46 2:41:20 PM
25001 AMX 14.46 2:41:31 PM
Table 3 (result)
Time ref-time sym exc price refprice
2:40:29 PM 2:39:54 PM AMX 25001 14.47 14.47
2:40:48 PM 2:40:36 PM AMX 25001 14.48 14.46
2:40:53 PM 2:40:36 PM AMX 25001 14.45 14.46
2:41:21 PM 2:41:20 PM AMX 25001 14.44 14.46
2:41:29 PM 2:41:20 PM AMX 25001 14.49 14.46
Simplified example where exchange and sym are held constant.
由于asof join
在代码中是(aj),因此table3的ref-time列与table2的ref-time列不同。
答案 0 :(得分:2)
看起来您刚刚复制了表1,然后根据Exc和sym从表2中查找了关联的ref-time和refprice。如果是这样,并假设像这样的数据集(请注意,表1和表2按Exc排序,然后按sym排序,然后按Time排序):
我最初将表1复制并按原样粘贴到K2中。然后,我为参考时间和参考价格插入了新列。
=MAX(INDEX($I$3:$I$7*($F$3:$F$7=M3)*($G$3:$G$7=N3)*($I$3:$I$7<=K3),))
=INDEX($H$3:$H$7,MATCH(1,INDEX(($F$3:$F$7=M3)*($G$3:$G$7=N3)*($I$3:$I$7=L3),),0))
调整范围以适合您的实际数据集。