查找单元格区域中满足条件的最后一个值

All*_*ons 6 worksheet-function libreoffice-calc

我正在 LibreOffice Calc 中寻找公式,以查找满足条件的范围内的最后一个值。这是示例数据:

A         B             C           D                E                 F
Date      US Amount     Currency    Local Amount     Exchange Rate     Reconciled
01/01/01  $1000.00      GBP         654 GBP          1.53              x
01/05/01  $1000.00      EUR         757.12 EUR       1.32              x
01/18/01  $1000.00      GBP         688 GBP          1.45              x
01/19/01  $1000.00      EUR         763.36 EUR       1.31              x
01/28/01  $1000.00      GBP         675.58 GBP       1.48
01/29/01  $1000.00      EUR         778.87 EUR       1.28
Run Code Online (Sandbox Code Playgroud)

因此,我正在寻找一个公式,可以得出适当货币的最后一致汇率。(在这种情况下,对于欧元,它将拉动 1.31,因为 1.28 尚未协调。)似乎在 Excel 中我可以使用 DLAST 函数,但这似乎尚未在 LibreOffice 中实现。

LibreOffice 有解决方法吗?

toh*_*ohu 4

是的 - 您可以使用该MATCH函数查找符合特定条件的最后一行。这样,您可以OFFSET根据第一行计算。它看起来像这样:

=OFFSET(E2;(MATCH("x";F1:F100;-1)-1);0;1)
Run Code Online (Sandbox Code Playgroud)

或者,插入一些中断和注释:

=OFFSET(              // find Offset ...
    E2;               // ... starting from first exchange rate ...
    (                 // ... and go down some rows:
        MATCH(        // get row of last reconciled rate using MATCH:
            "x";      // search for "x" ...
            F2:F100;  // in F1 to F100 (make sure that the range covers all rates!)
            -1        // assuming a descending sort order. So, the last of a sequence
                      // of identical values is the "first" one.
        )-1           // MATCH would return 4, so OFFSET would point to 5,
                      // so reduce by -1
    );
    0;                // no "horizontal" offset (stay in the same column)
    1)                // return only one cell
Run Code Online (Sandbox Code Playgroud)

  • 是的,基于适用于上次调节的欧元汇率的样本数据,但这不适用于上次调节的英镑汇率。无论它是什么货币,这总是会给我最后的调节汇率。我想更多的是有两个条件,一是汇率是否“对账”,二是汇率是什么。那有意义吗? (2认同)