Google Sheets - 如何计算一列上非零数字的条纹

发布于 2025-01-10 09:24:14 字数 264 浏览 3 评论 0原文

我有一个包含各种数字的字数列,但每个单元格都有一个公式。所以我想只计算具有非零数字的单元格,并在其达到零时停止。换句话说,就是连胜。

100
200
400
100
200
0
200
300
0

本例中最长的连续次数为 5。我可以使用什么公式来实现此目的?我已经尝试过了,但它正在寻找空白单元格而不是带有“0”的单元格 =ArrayFormula(match(TRUE,ISBLANK('每日计数'!B2:B),0)-1)

I have a wordcount column with various numbers but each cell has a formula. So I'd like to count only the cells that have a non-zero number and stop when it hits a zero. A streak in other words.

100
200
400
100
200
0
200
300
0

the longest streak in this example would be 5. What formula could I use for this? I've tried this already, but it's looking for blank cells not cells with "0"
=ArrayFormula(match(TRUE,ISBLANK('Daily Count'!B2:B),0)-1)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

变身佩奇 2025-01-17 09:24:14

尝试:

=ARRAYFORMULA(MMULT(SPLIT(FLATTEN(SPLIT(TRIM(QUERY(A1:A,,9^9)), " 0 ", )), " ")*1, 
   SEQUENCE(COLUMNS(SPLIT(FLATTEN(SPLIT(TRIM(QUERY(A1:A,,9^9)), " 0 ", )), " ")), 1, 1, )))

在此处输入图像描述

最长使用时间:

=INDEX(COLUMNS(SPLIT(FLATTEN(SPLIT(TRIM(QUERY(A1:A,,9^9)), " 0 ", )), " ")))

在此处输入图像描述

列出所有罢工:

=ARRAYFORMULA(LEN(QUERY(SUBSTITUTE(FLATTEN(SPLIT(TRIM(QUERY(
 IF(A1:A<>0, 1, 0),,9^9))&" ", " 0 ", )), " ", ), "where Col1 <> '0'")))

在此处输入图像描述

try:

=ARRAYFORMULA(MMULT(SPLIT(FLATTEN(SPLIT(TRIM(QUERY(A1:A,,9^9)), " 0 ", )), " ")*1, 
   SEQUENCE(COLUMNS(SPLIT(FLATTEN(SPLIT(TRIM(QUERY(A1:A,,9^9)), " 0 ", )), " ")), 1, 1, )))

enter image description here

for longest strike use:

=INDEX(COLUMNS(SPLIT(FLATTEN(SPLIT(TRIM(QUERY(A1:A,,9^9)), " 0 ", )), " ")))

enter image description here

to list all strikes:

=ARRAYFORMULA(LEN(QUERY(SUBSTITUTE(FLATTEN(SPLIT(TRIM(QUERY(
 IF(A1:A<>0, 1, 0),,9^9))&" ", " 0 ", )), " ", ), "where Col1 <> '0'")))

enter image description here

枯叶蝶 2025-01-17 09:24:14

经典方法(在 Excel 中也适用相同的方法)是使用频率:

=ArrayFormula(max(frequency(if(B2:B>0,row(B2:B)),if(B2:B<=0,row(B2:B)))))

在此处输入图像描述

The classic way (same method works in Excel) is to use Frequency:

=ArrayFormula(max(frequency(if(B2:B>0,row(B2:B)),if(B2:B<=0,row(B2:B)))))

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文