简体   繁体   中英

Excel - Lookup the group based on value range per segment

I have a table like below.

segmentnum  group 1 group 2 group 3 group 4
1           0       12      33      66
2           0       3       10      26
3           0       422     1433    3330

And a table like below.

vol     segmentnum  
0       1           
58      1           
66      1           
48      1           
9       2           
13      2           
7       2           
10      3           
1500    3           

I'd like to add a column that tells me which group the vol for a given segmentnum belongs to. Such that

Group 1 = x to < group 2
Group 2 = x to < group 3
Group 3 = x to <= group 4

Desired result:

vol     segmentnum  group
0       1           1
58      1           3
66      1           3
48      1           3
9       2           2
13      2           3
7       2           2
10      3           3
1500    3           3

Per the accompanying image, put this in I2 and drag down.

=MATCH(G2, INDEX(B$2:E$4, MATCH(H2, A$2:A$4, 0), 0))

在此输入图像描述

While these results differ from yours, I believe they are correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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