对于列值相等的每个组,获取大号和小号,并返回第三个列值 [英] Get Large and Small for every group where a column value is equal and return a 3rd column value

查看:39
本文介绍了对于列值相等的每个组,获取大号和小号,并返回第三个列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量的数据(约500,000行)包含水位信息.一共有3列.

I have a large set of data (approx. 500,000 rows) with water level information. There are 3 columns.

A: the water level (i.e. 0.7)
B: the date (i.e. 03/01/16)
C: the time (i.e 6:06:00)

我需要每天B从A获得2个最大值和2个最小值,然后返回A&C.

I need to get the 2 largest and 2 smallest values from A for every day B and return A & C.

因此,基本上,对于日期相等的所有行,找到最大和较小的值,然后告诉我这些值,并给我相关的时间.

So basically for all the rows where the date is equal find the largest and smaller tell me those values and give me the associated time.

这里有一些数据:

2.730 |16年3月4日|3:54:00
2.734 |16年3月4日|3:36:00
2.735 |16年3月4日|3:48:00
2.736 |16年3月4日|3:42:00
0.046 |16年3月5日|10:30:00
0.047 |16年3月5日|10:36:00
0.048 |16年3月5日|10:24:00
0.050 |16年3月5日|10:42:00
0.052 |16年3月5日|10:18:00
0.056 |16年3月5日|10:48:00

2.730 | 03/04/16 | 3:54:00
2.734 | 03/04/16 | 3:36:00
2.735 | 03/04/16 | 3:48:00
2.736 | 03/04/16 | 3:42:00
0.046 | 03/05/16 | 10:30:00
0.047 | 03/05/16 | 10:36:00
0.048 | 03/05/16 | 10:24:00
0.050 | 03/05/16 | 10:42:00
0.052 | 03/05/16 | 10:18:00
0.056 | 03/05/16 | 10:48:00

5年中每天大约有240行.最后,我想要一张桌子,只显示每天随着时间变化的高潮和低谷.

There are approximately 240 rows for every day for 5 years. In the end I want a table with just the highs and lows from every day with the time.

我尝试了各种解决方案,例如

I have tried various solutions like

= LARGE(A2:A241,1)

=LARGE(A2:A241,1)

在A列和

= VLOOKUP(F2,A2:C241,2,FALSE)

=VLOOKUP(F2,A2:C241,2,FALSE)

来获取关联的数据,但是我不知道如何在不手动选择每天并执行1826次公式的情况下连续几天进行处理.请帮忙.谢谢.

to grab the associated data, but I have no idea how to do it for multiple days without manually selecting each day and doing the formula 1826 times. Please Help. Thanks.

推荐答案

对于这么大的数据集,您希望避免使用数组公式,因此最好限制Small()或Large()的查找范围的方法.

With such a large data set you want to avoid array formulas, so an approach that limits the lookup range for a Small() or Large() is better.

考虑屏幕截图和公式结果.我在E2中输入了第一个日期,并使用填充手柄向下拖动并自动递增.我的日期以DMY顺序显示.

Consider the screenshot and the results of the formulas. I entered the first date in E2 and used the fill handle to drag down and auto-increment. My dates display in DMY order.

公式是

F2 = LARGE(INDEX($ A:$ A,MATCH($ E2,$ B:$ B,0)):INDEX($ A:$ A,MATCH($ E2,$ B:$B,1)),1)

G2 = LARGE(INDEX($ A:$ A,MATCH($ E2,$ B:$ B,0)):INDEX($ A:$ A,MATCH($ E2,$ B:$B,1)),2)

H2 = SMALL(INDEX($ A:$ A,MATCH($ E2,$ B:$ B,0)):INDEX($ A:$ A,MATCH($ E2,$ B:$B,1)),1)

I2 = SMALL(INDEX($ A:$ A,MATCH($ E2,$ B:$ B,0)):INDEX($ A:$ A,MATCH($ E2,$ B:$B,1)),2)

....复制下来.这种方法要求数据按B列中的日期升序排序.

.... copied down. This approach requires that the data is sorted ascending by the dates in column B.

要从C列返回匹配值,请将公式包装在C列的索引中,将A列与Match匹配,例如,第二个最小的时间是

To return the matching value from column C, wrap the formula in an Index on column C with a Match on column A, for example the time for the 2nd Smallest is

=INDEX($C:$C,MATCH(SMALL(INDEX($A:$A,MATCH($E2,$B:$B,0)):INDEX($A:$A,MATCH($E2,$B:$B,1)),2),$A:$A,0))

这篇关于对于列值相等的每个组,获取大号和小号,并返回第三个列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆