在Excel / Google Spreadsheets中显示基于标签的相邻单元格之间的差异

时间:2017-03-04 16:21:57

标签: excel formula difference

我在Excel / Google Spreadsheets中创建了一个系统,其中数据从原始数字转换为更小的通用类别。该系统的目的是测量数据集中每年的变化。我想计算行中从一个单元格到下一个单元格的差异,并将数据分割为20个不同的步骤。

所以我有一个原始数据的电子表格,如下所示:

enter image description here

然后我有一组像这样的类别。右边的列表示上一年的价值增加或减少:

enter image description here

所以我需要一个可以兼得的公式:

  • 计算当前单元格与单元格之间的差异 它的左边。
  • 然后根据"更改步骤"找出要输入的号码。我张贴了一张照片的专栏。

目前我有以下公式:

    =IF(AND(Data!B12-Data!C12<Formula!S2),"1",
IF(AND((Data!B12-Data!C12>Formula!S2,Data!B12-Data!C12<Formula!S3),"2",
IF(AND(Data!B12-Data!C12>Formula!S3, Data!B12-Data!C12<Formula!S4),"3",
IF(AND(Data!B12-Data!C12>Formula!S4, Data!B12-Data!C12<Formula!S5),"4",
IF(AND(Data!B12-Data!C12>Formula!S5, Data!B12-Data!C12<Formula!S6),"5",
IF(AND(Data!B12-Data!C12>Formula!S6, Data!B12-Data!C12<Formula!S7),"6",
IF(AND(Data!B12-Data!C12>Formula!S7, Data!B12-Data!C12<Formula!S8),"7",
IF(AND(Data!B12-Data!C12>Formula!S8, Data!B12-Data!C12<Formula!S9),"8",
IF(AND(Data!B12-Data!C12>Formula!S9, Data!B12-Data!C12<Formula!S10),"9",
IF(AND(Data!B12-Data!C12>Formula!S10, Data!B12-Data!C12<Formula!S11),"10",
IF(AND(Data!B12-Data!C12>Formula!S11, Data!B12-Data!C12<Formula!S12),"11",
IF(AND(Data!B12-Data!C12>Formula!S12, Data!B12-Data!C12<Formula!S13),"12",
IF(AND(Data!B12-Data!C12>Formula!S13, Data!B12-Data!C12<Formula!S14),"13",
IF(AND(Data!B12-Data!C12>Formula!S14, Data!B12-Data!C12<Formula!S15),"14",
IF(AND(Data!B12-Data!C12>Formula!S15, Data!B12-Data!C12<Formula!S16),"15",
IF(AND(Data!B12-Data!C12>Formula!S16, Data!B12-Data!C12<Formula!S17),"16",
IF(AND(Data!B12-Data!C12>Formula!S17, Data!B12-Data!C12<Formula!S18),"17",
IF(AND(Data!B12-Data!C12>Formula!S18, Data!B12-Data!C12<Formula!S19),"18",
IF(AND(Data!B12-Data!C12>Formula!S19, Data!B12-Data!C12<Formula!S20),"19",
IF(AND(Data!B12-Data!C12>Formula!S20, Data!B12-Data!C12<Formula!S21),"20",
)))))))))))))))))))))

我认为这会奏效,但我得到的只是#ERROR!。有小费吗?

2 个答案:

答案 0 :(得分:0)

如果您的Change steps:(#1,#2,#3等)位于Formula sheet的R列中,则以下 INDEX / MATCH函数应该执行此操作:

=IF(Data!B12-Data!C12<Formula!$S$2,1,SUBSTITUTE(INDEX(Formula!$R$2:$R$21,MATCH(Data!B12-Data!C12,Formula!$S$2:$S$21,1)),"#","")+1)

在公式表中设置:

enter image description here

结果:

enter image description here

答案 1 :(得分:0)

我自己想通了。正确的公式:

IF(AND(OFFSET(INDIRECT("Data!"&address(row(),column())),0,-1)-ABS(INDIRECT("Data!"&address(row(),column())))>Formel!J3, OFFSET(INDIRECT("Data!"&address(row(),column())),0,-1)-ABS(INDIRECT("Data!"&address(row(),column())))<Formel!J4), "2",

等等。