英文:
Extract Excel items in time range to consecutive time
问题
这是一个包含时间范围内项目的简单表格。期望的结果表格将所有项目映射到它们连续的时间段。你建议使用什么公式来完成这个任务?谢谢!
原始表格:
项目 | 开始时间 | 结束时间 |
---|---|---|
BE | 8:00 AM | 8:02 AM |
zeta | 8:06 AM | 8:24 AM |
gamma | 8:13 AM | 9:02 AM |
beta | 8:49 AM | 9:13 AM |
BE | 8:56 AM | 8:58 AM |
结果表格:
时间 | BE | zeta | gamma | beta |
---|---|---|---|---|
8:00 AM | Y | |||
8:01 AM | Y | |||
8:02 AM | Y | |||
8:03 AM | ||||
8:04 AM | ||||
8:05 AM | ||||
8:06 AM | Y | |||
8:07 AM | Y | |||
8:08 AM | Y | |||
8:09 AM | Y | |||
8:10 AM | Y | |||
8:11 AM | Y | |||
8:12 AM | Y | |||
8:13 AM | Y | Y | ||
8:14 AM | Y | Y | ||
8:15 AM | Y | Y | ||
8:16 AM | Y | Y | ||
8:17 AM | Y | Y | ||
8:18 AM | Y | Y | ||
8:19 AM | Y | Y | ||
8:20 AM | Y | Y | ||
8:21 AM | Y | Y | ||
8:22 AM | Y | Y | ||
8:23 AM | Y | Y | ||
8:24 AM | Y | Y | ||
8:25 AM | Y | |||
8:26 AM | Y | |||
8:27 AM | Y | |||
8:28 AM | Y | |||
8:29 AM | Y | |||
8:30 AM | Y | |||
8:31 AM | Y | |||
8:32 AM | Y | |||
8:33 AM | Y | |||
8:34 AM | Y | |||
8:35 AM | Y | |||
8:36 AM | Y | |||
8:37 AM | Y | |||
8:38 AM | Y | |||
8:39 AM | Y | |||
8:40 AM | Y | |||
8:41 AM | Y | |||
8:42 AM | Y | |||
8:43 AM | Y | |||
8:44 AM | Y | |||
8:45 AM | Y | |||
8:46 AM | Y | |||
8:47 AM | Y | |||
8:48 AM | Y | |||
8:49 AM | Y | Y | ||
8:50 AM | Y | Y | ||
8:51 AM | Y | Y | ||
8:52 AM | Y | Y | ||
8:53 AM | Y | Y | ||
8:54 AM | Y | Y | ||
8:55 AM | Y | Y | ||
8:56 AM | Y | Y | Y | |
8:57 AM | Y | Y | Y | |
8:58 AM | Y | Y | Y | |
8:59 AM | Y | Y | ||
9:00 AM | Y | Y | ||
9:01 AM | Y | Y | ||
9:02 AM | Y | Y | ||
9:03 AM | Y | |||
9:04 AM | Y | |||
9:05 AM | Y | |||
9:06 AM | Y | |||
9:07 AM | Y | |||
9:08 AM | Y | |||
9:09 AM | Y | |||
9:10 AM | Y | |||
9:11 AM | Y | |||
9:12 AM | Y | |||
9:13 AM | Y | |||
9:14 AM | ||||
9:15 AM |
编辑:
我刚刚注意到SUMPRODUCT()函数对大多数情况有效,但Beta在结果表格中缺少第一分钟(8:49 AM)。文件在这里,https://u.pcloud.link/publink/show?code=XZDCONVZ6mQCoqWVEJB0W7AKyLTvNje9z3IX
有什么想法吗?
英文:
Here’s a simple table with items in a time range. The desired result table has all items mapped to their consecutive time slots. What formula would you suggest accomplishing this task? Thanks!
Original table:
Item | Start | End |
---|---|---|
BE | 8:00 AM | 8:02 AM |
zeta | 8:06 AM | 8:24 AM |
gamma | 8:13 AM | 9:02 AM |
beta | 8:49 AM | 9:13 AM |
BE | 8:56 AM | 8:58 AM |
Result table:
Time | BE | zeta | gamma | beta |
---|---|---|---|---|
8:00 AM | Y | |||
8:01 AM | Y | |||
8:02 AM | Y | |||
8:03 AM | ||||
8:04 AM | ||||
8:05 AM | ||||
8:06 AM | Y | |||
8:07 AM | Y | |||
8:08 AM | Y | |||
8:09 AM | Y | |||
8:10 AM | Y | |||
8:11 AM | Y | |||
8:12 AM | Y | |||
8:13 AM | Y | Y | ||
8:14 AM | Y | Y | ||
8:15 AM | Y | Y | ||
8:16 AM | Y | Y | ||
8:17 AM | Y | Y | ||
8:18 AM | Y | Y | ||
8:19 AM | Y | Y | ||
8:20 AM | Y | Y | ||
8:21 AM | Y | Y | ||
8:22 AM | Y | Y | ||
8:23 AM | Y | Y | ||
8:24 AM | Y | Y | ||
8:25 AM | Y | |||
8:26 AM | Y | |||
8:27 AM | Y | |||
8:28 AM | Y | |||
8:29 AM | Y | |||
8:30 AM | Y | |||
8:31 AM | Y | |||
8:32 AM | Y | |||
8:33 AM | Y | |||
8:34 AM | Y | |||
8:35 AM | Y | |||
8:36 AM | Y | |||
8:37 AM | Y | |||
8:38 AM | Y | |||
8:39 AM | Y | |||
8:40 AM | Y | |||
8:41 AM | Y | |||
8:42 AM | Y | |||
8:43 AM | Y | |||
8:44 AM | Y | |||
8:45 AM | Y | |||
8:46 AM | Y | |||
8:47 AM | Y | |||
8:48 AM | Y | |||
8:49 AM | Y | Y | ||
8:50 AM | Y | Y | ||
8:51 AM | Y | Y | ||
8:52 AM | Y | Y | ||
8:53 AM | Y | Y | ||
8:54 AM | Y | Y | ||
8:55 AM | Y | Y | ||
8:56 AM | Y | Y | Y | |
8:57 AM | Y | Y | Y | |
8:58 AM | Y | Y | Y | |
8:59 AM | Y | Y | ||
9:00 AM | Y | Y | ||
9:01 AM | Y | Y | ||
9:02 AM | Y | Y | ||
9:03 AM | Y | |||
9:04 AM | Y | |||
9:05 AM | Y | |||
9:06 AM | Y | |||
9:07 AM | Y | |||
9:08 AM | Y | |||
9:09 AM | Y | |||
9:10 AM | Y | |||
9:11 AM | Y | |||
9:12 AM | Y | |||
9:13 AM | Y | |||
9:14 AM | ||||
9:15 AM |
Edit:
I just noticed that SUMPRODUCT() worked for most, but Beta is missing the first minute in the result table (8:49 AM). File is here, https://u.pcloud.link/publink/show?code=XZDCONVZ6mQCoqWVEJB0W7AKyLTvNje9z3IX
Any ideas?
答案1
得分: 2
尝试使用<kbd>XMATCH( )</kbd>。
• 在单元格<kbd>F2</kbd>中使用的公式:
=IF(ISNUMBER(XMATCH(1,($E2>=$B$2:$B$6)*($E2<=$C$2:$C$6)*(F$1=$A$2:$A$6))),"Y","")
需要向下填充公式并向右填充,还请根据需要更改单元格引用和范围。
您还可以在<kbd>SUM( )</kbd>函数中使用<kbd>BOOLEAN LOGIC</kbd>。
• 在单元格<kbd>F2</kbd>中使用的公式:
=IF(SUM(($E2>=$B$2:$B$6)*($E2<=$C$2:$C$6)*(F$1=$A$2:$A$6)),"Y","")
由于 OP 使用的是 Excel 2007
,因此将使用<kbd>SUM( )</kbd>替换为<kbd>SUMPRODUCT( )</kbd>的公式,尽管<kbd>SUM( )</kbd>也可以工作,但需要在退出编辑模式时按下<kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>ENTER</kbd>,另外,由于您未使用更新的版本,可以使用<kbd>MATCH( )</kbd>函数代替<kbd>XMATCH( )</kbd>,但使用<kbd>SUMPRODUCT( )</kbd>比其他方法更快。
这是一个屏幕截图,显示了第一次 Beta 的时间为 8:49 AM
。
编辑于 2023 年 8 月 10 日
更新的公式:
=IF(SUMPRODUCT((TIME(HOUR($E2),MINUTE($E2),)>=$B$2:$B$6)*
(TIME(HOUR($E2),MINUTE($E2),)<=$C$2:$C$6)*
(F$1=$A$2:$A$6)),"Y","")
从这里下载工作簿:Workbook
英文:
Try using <kbd>XMATCH( )</kbd>
• Formula used in cell <kbd>F2</kbd>
=IF(ISNUMBER(XMATCH(1,($E2>=$B$2:$B$6)*($E2<=$C$2:$C$6)*(F$1=$A$2:$A$6))),"Y","")
Formula needs to fill down and fill right, also please try to change the cell references and ranges accordingly as per your suit.
You can also use a <kbd>BOOLEAN LOGIC</kbd> within a <kbd>SUM( )</kbd> function.
• Formula used in cell <kbd>F2</kbd>
=IF(SUM(($E2>=$B$2:$B$6)*($E2<=$C$2:$C$6)*(F$1=$A$2:$A$6)),"Y","")
Since OP is using Excel 2007
hence replace the formula using <kbd>SUM( )</kbd> with <kbd>SUMPRODUCT( )</kbd> although the <kbd>SUM( )</kbd> would work but it would need to hit <kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>ENTER</kbd> while exiting the edit mode, also since you are not using the updated version, you can use <kbd>MATCH( )</kbd> function in place of <kbd>XMATCH( )</kbd> but using <kbd>SUMPRODUCT( )</kbd> will be faster than the rest.
Here is a screenshot where it shows it is not missing the first time 8:49 AM
for Beta
Edit 8/10/2023
Updated formula:
=IF(SUMPRODUCT((TIME(HOUR($E2),MINUTE($E2),)>=$B$2:$B$6)*
(TIME(HOUR($E2),MINUTE($E2),)<=$C$2:$C$6)*
(F$1=$A$2:$A$6)),"Y","")
Download the workbook from here: Workbook
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论