Selecting values in a list based on an interval?

2019-07-15 10:03发布

I have a large column of values representing elevation in metres. Here is an example:

177.5
178.0
180.1
181.9
182.4
182.5
184.0
185.3

I want to create formula in a different column that gives a 1 for every 2.5m interval or the first value after the interval. Here are the the numbers I would be searching for based on the 2.5 interval:

177.5
180.0
182.5
185.0

Since I don't have those exact numbers in my original list, I want the formula to place a 1 in the corresponding column next to the following numbers from the list:

177.5
180.1
182.5
185.3

What kind of formula would I be looking for? I'm not too sure what to call this kind of problem otherwise I'd have an easier time searching for it on stackoverflow.

1条回答
甜甜的少女心
2楼-- · 2019-07-15 10:10

Something like the below image may work. Note the formula in B2 filling down is: =IF(A3>=SUM($B$2:B2)*$C$1+$E$1,1,0)

  • Requires that A be sorted,
  • Requires that C1 contain the interval searching for
  • Requires that B contain a 1 indicating the starting value
  • uses $ to denote fixed postion since the range on the sum moves it had to be dynamic the rest of the values were static.
  • Doesn't handle voids. Say if you skipped from 185 to 200. it will flag 200, and even 199 because 199 is the next closest number to the interval after 187.5 which would have been 190

enter image description here

查看更多
登录 后发表回答