简体   繁体   English

Excel动态范围偏移量公式不包含#n / a

[英]Excel dynamic range offset formula exclude #n/a

I have data that changes depending on the slicer, and I can't figure out the correct offset formula to select only data values that are valid or in other words, exclude any #N/A values. 我的数据会根据切片器而变化,并且我无法找出正确的偏移量公式来仅选择有效的数据值,或者换句话说,排除任何#N / A值。 The data looks something like this: 数据看起来像这样:

|Column A   |  Column B   |Column C|
|----------------------------------|
|Jan        |   #N/A      |    #N/A|
|Feb        |   4         |     40 |
|Mar        |   5         |    38  |
|Apr        |   12        |     10 |
|May        |   #N/A      |    #N/A|
|Jun        |   #N/A      |    #N/A|

I want the offset range to select only Feb/Mar/Apr rows. 我希望偏移量范围仅选择2月/ 3月/ 4月行。 But if the data changes because I click on a different filter (example below), I want it to still select only the non-error data (rows Jan/Feb/Mar/Apr): 但是,如果数据因我单击其他过滤器而发生更改(下面的示例),我希望它仍仅选择非错误数据(行Jan / Feb / Mar / Apr):

|Column A   |  Column B  | Column C|
|----------------------------------|
|Jan        |   30       |      60 |
|Feb        |   8        |      83 |
|Mar        |   53       |      14 |
|Apr        |   11       |      41 |
|May        |   #N/A     |     #N/A|
|Jun        |   #N/A     |     #N/A|

Please help! 请帮忙! Thank you. 谢谢。

The offset function can only select a single range of cells, however this should still be suitable for your needs. 偏移功能只能选择单个范围的单元格,但是这仍应适合您的需求。 A graph with months along the x-axis should include all months even if there isn't a value. 即使没有值,在x轴上带有月份的图形也应包括所有月份。 The offset function will just cause the graph to start at the earliest month with a value and finish at the latest month with a value. 偏移功能只会使图形从一个值的最早月份开始,到一个值的最近月份结束。 Any months in between without a value will just have nothing plotted on the chart. 之间的任何月份如果没有值,则图表上将没有任何内容。

To use named ranges in a chart, you have to name each individual series. 要在图表中使用命名范围,必须命名每个单独的系列。 You can't use a dynamic range for the entire chart source data range. 您不能为整个图表源数据范围都使用动态范围。

Define the following three named ranges for use in your chart. 定义以下三个命名范围以在图表中使用。 There is one named range for each column A, B and C. Each named range looks at Column B to determine which rows to include: A,B和C列各有一个命名范围。每个命名范围都会查看B列以确定要包括的行:

Months: 月份:

=IF(COUNT(Sheet1!$B$2:$B$7)=0,Sheet1!$A$2,OFFSET(Sheet1!$A$1,MIN(IF(ISERROR(Sheet1!$B$2:$B$7),"",ROW(Sheet1!$B$2:$B$7)))-1,0,MAX(IF(ISERROR(Sheet1!$B$2:$B$7),"",ROW(Sheet1!$B$2:$B$7)))-MIN(IF(ISERROR(Sheet1!$B$2:$B$7),"",ROW(Sheet1!$B$2:$B$7)))+1,1))

Series1: 系列1:

=IF(COUNT(Sheet1!$B$2:$B$7)=0,Sheet1!$B$2,OFFSET(Sheet1!$B$1,MIN(IF(ISERROR(Sheet1!$B$2:$B$7),"",ROW(Sheet1!$B$2:$B$7)))-1,0,MAX(IF(ISERROR(Sheet1!$B$2:$B$7),"",ROW(Sheet1!$B$2:$B$7)))-MIN(IF(ISERROR(Sheet1!$B$2:$B$7),"",ROW(Sheet1!$B$2:$B$7)))+1,1))

Series2: 系列2:

=IF(COUNT(Sheet1!$B$2:$B$7)=0,Sheet1!$C$2,OFFSET(Sheet1!$C$1,MIN(IF(ISERROR(Sheet1!$B$2:$B$7),"",ROW(Sheet1!$B$2:$B$7)))-1,0,MAX(IF(ISERROR(Sheet1!$B$2:$B$7),"",ROW(Sheet1!$B$2:$B$7)))-MIN(IF(ISERROR(Sheet1!$B$2:$B$7),"",ROW(Sheet1!$B$2:$B$7)))+1,1))

You can then set up your chart, but remember you need to add/edit each series individually. 然后,您可以设置图表,但请记住,您需要分别添加/编辑每个系列。 Ignore the Chart Data Range field: 忽略“图表数据范围”字段:

图表

When you set each series or x-axis to the named range, you need to qualify it with a reference to the current worksheet or workbook. 将每个系列或x轴设置为指定的范围时,需要使用对当前工作表或工作簿的引用来对其进行限定。 If you just specify the range name, Excel won't recognize it: 如果仅指定范围名称,Excel将无法识别它:

编辑系列

轴标

After you have set everything up, the Chart Data Range field will show the consolidated range that covers all data for your change. 设置完所有内容后,“图表数据范围”字段将显示合并的范围,该范围涵盖您所做更改的所有数据。 Do not touch this field. 请勿触摸此字段。 The dynamic ranges have been set for the series. 已为该系列设置了动态范围。 As your data changes, FMS will automatically recalculate the Chart Data Range. 随着数据的更改,FMS将自动重新计算图表数据范围。

更新范围

Joyce, You can create an additional set of cells with same dimension and use those cells in your offset. 乔伊斯,您可以创建其他一组具有相同尺寸的单元格,并在偏移中使用这些单元格。 For creating the additional set of cells. 用于创建其他单元格集。 Choose any one cell and enter the below formula as Array formula. 选择一个单元格,然后输入以下公式作为“数组公式”。 (Enter the below formula and then press shift + enter). (输入以下公式,然后按Shift + Enter)。 Then copy that cell to all other cells as mentioned in the attached image. 然后,如所附图像中所述,将该单元格复制到所有其他单元格中。 Then you can base that new set of cells in your offset. 然后,您可以将新的一组单元格作为偏移量的基础。 I believe, this will address your requirements. 我相信,这将满足您的要求。 No matter whether the rows or continuous or errors in between. 无论是行还是连续的,还是介于两者之间的错误。 If you use the offset function of the new set of cells, which would have only the non-error data and you can make a graph using that, and the graph will change according to the slicer. 如果您使用新单元格集合的偏移功能,那么该偏移量功能将只包含非错误数据,则可以使用该函数来制作图形,并且图形将根据切片器而变化。 Only assumption that I made is that, if it is error both column B and Column C will have the error value. 我所做的唯一假设是,如果出错,则B列和C列都将具有错误值。 So, it filters only based on the value in column B. 因此,它仅基于列B中的值进行过滤。

=IFERROR(INDEX($A$1:$C$10,SMALL(IF(ISERROR($B$2:$B$10),"",ROW($B$2:$B$10)),ROW(A1)),COLUMN(A1)),"")

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM