搜索多个日期范围的日期并返回相应的值 [英] Search a date in multiple date ranges and return the corresponding value

查看:118
本文介绍了搜索多个日期范围的日期并返回相应的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在表1中,我按照时间顺序在A列中列出日期。在列B中有与此列表相对应的值。表2中还有另一个日期列表,我想从表1添加这些日期的值。

 表1. 

**列A列B
日期金额**
1. 10/01/2015 25,60,000
2. 10/02/2015 26,80,000
3. 01/03/2015 21,55,000
4. 30/03/2015 24,60,500
5. 30/04/2015 28 ,20,000
6. 30/06/2015 19,00,000

表2.

列A列B
1. 21/02/2015 21,55,000
2. 15/01/2015
3. 20/05/2015
4. 25/04/2015

例如:我需要在表1和列A中查找21/02/2015,并返回与下一个可用日期相对应的值。所以对于21/02/2015,我需要与下一个可用日期相对应的值,即01/03/2015,值为21,55,000。如果它的15/01/2015我需要10/02/2015的价值,即26,80,000



我可以使用什么公式?

解决方案

您可以使用VLOOKUP,但有一些问题。所以最好使用INDEX和MATCH组合。在你的情况下,尝试这个

  = INDEX('Sheet 1'!$ B:$ B,MATCH(A1,'Sheet 1 $!$ A:$ A,-1))






对不起,我以前的答案仅适用于降序。尝试这样做

  = INDEX('Sheet 1'!$ B:$ B,MATCH(TRUE,('Sheet 1' !$ A:$ A-A1)= MIN(IF('Sheet 1'!$ A:$ A-A1> = 0,'Sheet 1'!$ A:$ A-A1)),0))






说明:希望 INDEX MATCH 在Office支持中有很好的解释。



关于条件:

 ('Sheet 1'!$ A:$ A-A1) = MIN(IF('Sheet 1'!$ A:$ A-A1> = 0,'Sheet 1'!$ A:$ A-A1))

这是什么意思?

 'Sheet 1'!$ A: $ A-A1 

导致单元格中的值之间的差异 A1 和Sheet 1中A列中的单元格。

  MIN(IF('Sheet 1'! $ A:$ A-A1> = 0, '$ 1:$ A-A1))

说如果差异是非 - $($ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $)
$ b

如果这些数字相等(MATCH函数),则在列B中选择相应的数字( INDEX('Sheet 1'!$ B:$ B,.. )。






道歉:在我以前的答案中,我交换了你的例子的列。我希望现在是正确的。


In sheet 1, I have a list of dates in Column A in chronological order. There are values corresponding to this list in Column B. There is another list of dates in sheet 2 and I want to add values from sheet 1 to these dates.

Sheet 1.

     **Column A       Column B
      DATE            Amount**
1.  10/01/2015      25,60,000
2.  10/02/2015      26,80,000
3.  01/03/2015      21,55,000
4.  30/03/2015      24,60,500
5.  30/04/2015      28,20,000
6.  30/06/2015      19,00,000

Sheet 2.

     Column A      Column B
1.  21/02/2015     21,55,000
2.  15/01/2015
3.  20/05/2015
4.  25/04/2015

For example: I need to look up 21/02/2015 in sheet 1 and column A and return the value corresponding to the next available date. So for 21/02/2015 I need the value corresponding to the next date available which is 01/03/2015 and the value is 21,55,000. If its 15/01/2015 I need the value of 10/02/2015 i.e. 26,80,000

What formula could I use for this?

解决方案

You could use VLOOKUP, but it has some issues. So it is better to use INDEX and MATCH combination. In your case try this

=INDEX('Sheet 1'!$B:$B,MATCH(A1,'Sheet 1'!$A:$A,-1))


Sorry, my previous answer works only for descending order. Try this instead

=INDEX('Sheet 1'!$B:$B,MATCH(TRUE,('Sheet 1'!$A:$A-A1)=MIN(IF('Sheet 1'!$A:$A-A1>=0,'Sheet 1'!$A:$A-A1)),0))


Explanation: I hope that INDEX and MATCH are well explained in Office Support.

About the condition:

('Sheet 1'!$A:$A-A1)=MIN(IF('Sheet 1'!$A:$A-A1>=0,'Sheet 1'!$A:$A-A1))

What it means?

'Sheet 1'!$A:$A-A1

results in a difference between the value in the cell A1 and the cell in A column in Sheet 1.

MIN(IF('Sheet 1'!$A:$A-A1>=0,'Sheet 1'!$A:$A-A1))

says that if the difference is non-negative ('Sheet 1'!$A:$A-A1>=0), find the minimum of such numbers (MIN function).

And if these numbers are equal (MATCH function), then pick the corresponding number in column B (INDEX('Sheet 1'!$B:$B,...)).


Apology: In my previous answers I swapped the columns of your example. I hope it is now correct.

这篇关于搜索多个日期范围的日期并返回相应的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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