[英]Google Sheets; Finding the first cell to contain 0 in a column where the row number is > the row number generated in another formula
I'm making a document in Google sheets that produces the start and end times where a number of people are in a section.我正在 Google 表格中制作一个文档,该文档会生成一个部分中有很多人的开始和结束时间。 I was able to produce a grid, but I can't seem to find a formula for calculating end times that occur after the start time.
我能够生成一个网格,但我似乎找不到计算开始时间之后发生的结束时间的公式。
Time![]() |
Section1![]() |
Section2![]() |
---|---|---|
9:00am ![]() |
1 ![]() |
0 ![]() |
9:30am![]() |
1 ![]() |
0 ![]() |
10:00am ![]() |
1 ![]() |
1 ![]() |
10:30am![]() |
0 ![]() |
1 ![]() |
I want to make a series of formulas that list the start and end times when people are present in a section.我想制作一系列公式,列出人们出现在某个部分的开始和结束时间。
For the first part, I can find the start time with the formula对于第一部分,我可以用公式找到开始时间
=IFNA(INDEX($A$2:$A,(MATCH(TRUE,INDEX($B$2:$B>0,0),0))))
But when I try to adapt it to the end time by changing the greater than (>) to equals (=), it gives me the first time there is a zero regardless of if it occurs before the start time.但是,当我尝试通过将大于 (>) 更改为等于 (=) 来使其适应结束时间时,无论它是否发生在开始时间之前,它都会第一次给我一个零。 I feel like adding some kind of row check will be necessary to fix this, but I'm not sure how.
我觉得有必要添加某种行检查来解决这个问题,但我不确定如何。 I would really rather not learn Google API if at all possible,
如果可能的话,我真的宁愿不学习谷歌 API,
If it's just to find the first 0 after a 1, you could benefit from the use of INDEX and MATCH to create a range that goes from the first 1 to the last row and look the 0 in that range.如果只是查找 1 之后的第一个 0,您可以使用 INDEX 和 MATCH 创建一个从第一个 1 到最后一行的范围并查看该范围内的 0。 That is:
INDEX(B2:B,MATCH(1,B2:B,0)):INDEX(B2:B,ROWS(B2:B))
So, inserted in the whole formula:即:
INDEX(B2:B,MATCH(1,B2:B,0)):INDEX(B2:B,ROWS(B2:B))
因此,插入整个公式:
=INDEX(A2:A,MATCH(1,B2:B,0) + MATCH(0, INDEX(B2:B,MATCH(1,B2:B,0)):INDEX(B2:B,ROWS(B2:B)) ,0)-1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.