简体   繁体   English

获取行之间的最大变化,忽略列表末尾的空单元格

[英]Get max change between rows, ignoring empty cells at end of list

I have a spreadsheet where I'm tracking my net worth over time.我有一个电子表格,我在其中跟踪我的净资产随着时间的推移。 Once a month, I add in my account balances.每月一次,我添加我的帐户余额。

In one sheet, I have this structure:在一张纸上,我有这样的结构:

Date日期 Year Net Worth净值 Account1帐户1 Account2账户2 Account3帐户3
Jan 31, 2021 2021 年 1 月 31 日 2021 2021 $320 320 美元 $200 200 美元 $140 140 美元 -$20 -$20
Feb 28, 2021 2021 年 2 月 28 日 2021 2021 $340 340 美元 $200 200 美元 $150 150 美元 -$10 -$10
Mar 31, 2021 2021 年 3 月 31 日 2021 2021 $410 410 美元 $250 250 美元 $200 200 美元 -$40 -$40
Apr 30, 2021 2021 年 4 月 30 日
May 31, 2021 2021 年 5 月 31 日

...rest of months for the year ...rest 月份的一年

The formula in the Year column is =if(C3<>"", year(A3), "") . Year 列中的公式为=if(C3<>"", year(A3), "")

The formula in the Net worth column is =if(sum(D3:F3)<>0, sum(D3:F3), "") .净值列中的公式是=if(sum(D3:F3)<>0, sum(D3:F3), "")

The Problem: I'd like to have a cell which lists the greatest 1 month change (so $410 - $340 = $70), without having to update the formula every month.问题:我想要一个列出 1 个月最大变化的单元格(因此 $410 - $340 = $70),而不必每个月更新公式。 (In an ideal world, I never need to touch it again, only ever having to enter account balances once a month.) (在一个理想的世界里,我永远不需要再碰它,只需要每月输入一次账户余额。)

What I've got so far:到目前为止我得到了什么:

=if(
  abs(min(ArrayFormula(C3:C400 - C2:C399)))=max(ArrayFormula(abs(C3:C400 - C2:C399))), 
  min(ArrayFormula(C3:C400 - C2:C399)),
  max(ArrayFormula(C3:C400 - C2:C399))
)

However, this includes the change from $410 to "" , which is coerced to $0.但是,这包括从 $410 到""的更改,这被强制更改为 $0。 So instead of the expected $70, I'm instead getting $410.因此,我得到的不是预期的 70 美元,而是 410 美元。

How can I get the greatest 1 month change, but ignore the empty string values?如何获得最大的 1 个月变化,但忽略空字符串值?

Easiest way to fix it is just to put in an if clause I think:解决它的最简单方法就是放入我认为的 if 子句:

=ArrayFormula(max(if(C3:C400<>"",abs(C3:C400-C2:C399),)))

because Max will ignore the empty string generated by the If statement因为 Max 会忽略 If 语句生成的空字符串

or slightly shorter:或略短:

=ArrayFormula(max((C3:C400<>"")*abs(C3:C400-C2:C399)))

so that the change for any empty cells is set to zero.以便将任何空单元格的更改设置为零。

These assume that C2 itself is not blank!这些假设 C2 本身不是空白的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM