[英]Selecting the max with a condition in excel
I have a range in excel with dates and values 我在Excel中有日期和值的范围
http://lh4.ggpht.com/_i-hI_3gfy08/SoSIopeZUZI/AAAAAAAABEk/KjFnq57VTUc/table.png EDIT:image added http://lh4.ggpht.com/_i-hI_3gfy08/SoSIopeZUZI/AAAAAAAABEk/KjFnq57VTUc/table.png编辑:添加了图像
I want to select the MAX value from the HIGH column for each YEAR (2009 would return 404, 2008 would return 390) 我想从每年的HIGH列中选择MAX值(2009年将返回404,2008年将返回390)
I've done something similar but it's using SUMIF, not MAX. 我做了类似的事情,但它使用的是SUMIF,而不是MAX。
Any excel people in here that can help me out? 这里有什么优秀的人才可以帮助我吗?
The equivalent of SUMIF
in Excel is something like this: Excel中的
SUMIF
等效项如下所示:
{=MAX(IF(CategoryColumn="High",ValueColumn,"")}
Where 哪里
CategoryColumn
is the column containing your categories (eg, "Low", "Med", "High") CategoryColumn
是包含您的类别(例如,“低”,“中”,“高”)的列 ValueColumn
is the column containing the data you want to get the max of ValueColumn
是包含要获取最大值的数据的列 NOTE: This is an array formula so you must press Ctrl-Shift-Enter when entering this formula instead of just Enter. 注意:这是一个数组公式,因此在输入此公式而不是Enter时必须按Ctrl-Shift- Enter。 Also, don't actually type in the braces
{}
. 另外,请勿实际输入大括号
{}
。 The braces show up automatically to indicate that you've entered an array formula. 大括号会自动显示,表明您已输入数组公式。
NOTE 2: You can actually name a range of data. 注意2:您实际上可以命名数据范围。 For example, select the range
A1:A20
. 例如,选择范围
A1:A20
。 Right-Click and select "Name a Range..." So, for this example, you can select your category column and name it CategoryColumn
. 右键单击并选择“命名范围...”,因此,对于本示例,您可以选择类别列并将其命名为
CategoryColumn
。 Same with ValueColumn
. 与
ValueColumn
相同。
Array formulas allow you to do IF
statements and other functions on a whole range of data instead of just a single value. 数组公式允许您对整个数据范围而不是单个值执行
IF
语句和其他函数。
This example checks if the value in the "category column" is "High". 本示例检查“类别列”中的值是否为“高”。 If it is, it puts the neighboring "value" into the
MAX
function, otherwise it puts a blank. 如果是,则将相邻的“值”放入
MAX
函数,否则将为空白。 This gives you the maximum of all the "High" values. 这将为您提供所有“高”值的最大值。
PS I don't think the img
tag works on this site...can't see your image. 附言:我认为
img
标签在此网站上不起作用...看不到您的图片。
There are three options available. 共有三个选项。
My preferred option is to create a pivot table without a helper column. 我的首选方法是创建一个没有帮助列的数据透视表。
Create a pivot table of your data. 创建数据的数据透视表。
Set the row to the date field and group it by year. 将行设置为日期字段,然后按年份分组。 Alternately a 'Year' helper column could be used by adding a column with this formula.
或者,可以通过添加具有此公式的列来使用“年度”帮助列。
=YEAR(A2)
Set the data items value portion of the pivot table to be the MAX of your 'High' field 将数据透视表的数据项值部分设置为“高”字段的最大值
Add a helper column titled year with the formula 使用公式添加标题为year的助手列
=YEAR(A2)
Then add a formula for each year 然后为每年添加一个公式
=DMAX(A1:C21,"High",F13:F14)
Enter an array formula for each year using the Ctrl-Shift-Enter keys. 使用Ctrl-Shift-Enter键输入每年的数组公式。
{=MAX(IF(YEAR(A2:A21)=2008,B2:B21))}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.