如何在Excel中的一列中识别和命名不同的范围?

发布于 2025-02-02 21:23:34 字数 533 浏览 2 评论 0原文

我有一个卡车的记录驱动周期,其中包括速度和随着时间的推移坐标。该文件看起来像这样(简化版本)

”“在此处输入图像说明”

我想知道卡车停止的次数(速度= 0时)并编号它们。因此,我想将间隔与'0'值(停止车辆停止)的间隔分组,然后按顺序命名(停止1,停止2等)。最终,我的目标是某种程度上能够计算出这样的停止次数和持续时间:

=“ https://i.sstatic.net/d21nc.png” alt =“在此处输入图像描述”>

Excel中是否有任何功能可以让我做这样的事情?谢谢。

I have a recorded drive cycle of a truck which includes speed and coordinates over time. The file looks like this (simplified version)

enter image description here

I want to know the number of times the truck is stopped (when speed = 0) and number them. Therefore, I would like to group the intervals with '0' values (vehicle stopped) in the Speed column and name them in order (Stop 1, Stop 2, etc). Ultimately, my goal would be to somehow be able to calculate the number of stops and duration like this:

enter image description here

Is there any function in Excel which would allow me to do something like that? Thank you.

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

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

发布评论

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

评论(2

会傲 2025-02-09 21:23:34

您可以使用枢轴表和辅助列进行操作。另外,如果您具有具有excel365,则具有诸如filter,unique and sumifs

”在此处输入图像说明“

公式助手列只是为了枚举每个停止量。请注意,需要正确对数据进行正确排序,否则该数据无法正常工作:

=IF(D2="STOP";IF(D1="STOP";E1;MAX($E$1:E1)+1);"")

可以插入枢轴表:

  1. 助手列车辆stop行 rows section
  2. 时间-Step Seconds分为值部分,形成为时间和操作= Sum
  3. Filter Field 助手列以排除空白,

如果您拥有Excel 365,则可以使用高级公式获得此输出。在Cell J14公式中为:

=UNIQUE(FILTER(D2:D19&E2:E19;D2:D19="STOP"))

和K14 IS(并且向下拖动)是:

=SUMIFS($B$2:$B$19;$D$2:$D$19;"STOP";$E$2:$E$19;MID(J14;5;99))

无论如何,我已将工作簿上传到GDRIVE,因此您可以自己看到枢轴表和公式。如果您不jave Excel 365,则在打开它时,配方零件可能会出现一些错误:

https://docs.google.com/spreadsheets/d/1t1INxGKJRHFexWnSC5LlIi37JrThjajs/edit?usp=sharing&ouid=114417674018837700466&rtpof=true&sd=true

You can do it using Pivot Tables and a helper column. Also if you have Excel365 with functions like FILTER,UNIQUE and SUMIFS

enter image description here

Formula helper column is just to enumerate properly each group of stops. Notice data need to be sorted properly as your exampel or it won't work:

=IF(D2="STOP";IF(D1="STOP";E1;MAX($E$1:E1)+1);"")

Then pivot table can be inserted:

  1. Helper Column and Vehicle Stop into rows section
  2. Time-step seconds into values section, formated as Time and operation=Sum
  3. Filter field Helper Column to exclude blanks

If you have Excel 365, you can get this output with advanced formulas. In cell J14 formula is:

=UNIQUE(FILTER(D2:D19&E2:E19;D2:D19="STOP"))

And K14 is (and drag down) is:

=SUMIFS($B$2:$B$19;$D$2:$D$19;"STOP";$E$2:$E$19;MID(J14;5;99))

Anyways, I've uploaded the workbook to Gdrive so you can see the Pivot Table and the formulas by yourself. If you don't jave Excel 365, the formulation part may give some errors when you open it:

https://docs.google.com/spreadsheets/d/1t1INxGKJRHFexWnSC5LlIi37JrThjajs/edit?usp=sharing&ouid=114417674018837700466&rtpof=true&sd=true

岁月如刀 2025-02-09 21:23:34

就像对此的后记一样,您可以通过比较偏移范围来查看速度从0到10到10(go)或10到0(停止)的速度发生在何处,而无需使用辅助列而不使用辅助列。问题是通常,您必须超出数据范围(A2:A16和C2:C16),该数据范围(A2:A16和C2:C16)可以使您一个标头单元格(A1或C1)或空白单元格(A17或C17)。在时间的情况下,还有一个特殊情况,即首次阶段为零。

通过使用VSTACK将适当的虚拟值添加到两个范围的起点或结尾:

=LET(timeRange,A2:A16,
speedRange,C2:C16,
timeRange1,VSTACK(A2,timeRange),
speedRange1,VSTACK(1,speedRange),
speedRange2,VSTACK(speedRange,1),
startTime,FILTER(timeRange1,(speedRange1>0)*(speedRange2=0)),
endTime,FILTER(timeRange1,(speedRange1=0)*(speedRange2>0)),
stopTime,endTime-startTime,
label,"STOP "&SEQUENCE(ROWS(stopTime)),
HSTACK(label,stopTime))

”在此处输入图像说明”

Just as a postscript to this, you could do the same thing without using helper columns by comparing offset ranges to see where the transitions in speed occurred from 0 to 10 (go) or 10 to 0 (stop). The problem is that normally you would have to go outside the data range (a2:a16 and c2:c16) which gets you either a header cell (a1 or c1) or a blank cell (a17 or c17). In the case of time, there is also a special case where the first time-step is taken to be zero.

All this can be avoided in Excel 365 by using vstack to add appropriate dummy values to the beginning or end of the two ranges:

=LET(timeRange,A2:A16,
speedRange,C2:C16,
timeRange1,VSTACK(A2,timeRange),
speedRange1,VSTACK(1,speedRange),
speedRange2,VSTACK(speedRange,1),
startTime,FILTER(timeRange1,(speedRange1>0)*(speedRange2=0)),
endTime,FILTER(timeRange1,(speedRange1=0)*(speedRange2>0)),
stopTime,endTime-startTime,
label,"STOP "&SEQUENCE(ROWS(stopTime)),
HSTACK(label,stopTime))

enter image description here

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