简体   繁体   中英

How do i use a lookup in excel to return a value from a third column, if criteria are met in 2 other columns

I have a dataset which has columns as follows. It shows me the number of people (in the time columns) that are in the room (resource) on date.

Sample Dataset:

样本数据集

I am attempting to return the following.

Sample Result:

样本结果

Essentially, im trying to search my dataset, and return the number of people in each room, at each time and date, in a more digestible manner.

Apologies if i havent explained myself correctly, and i havent really worked out how to use this forum properly yet, but i'm hoping to use the collective to help with this problem. I'm not an excel newbie, but i can't seem to get the right mix of match/index/v/hlookups to do what i need! Thanks :)

Ok, so updating based on NightCrawler's assistance, still getting random errors at 1 and 4pm! any tips?

定时错误

I achieved your desired result using this formula. I added another column to get correct dates in each row because i did not want to deal with merged cells (see image).

=SUMIFS(OFFSET($C$2:$C$7,0,MATCH($D11,$C$1:$L$1,0)-1),$A$2:$A$7,$B11,$B$2:$B$7,E$10)

Drag the formula to all cells

修订截图

Here is another method you could use

Select your data. Goto Data Tab. Under Get & Transform, click From Table. In the pop-up check My Table has headers -> OK

A window(Query Editor) will pop-up.

查询编辑器

Select your time columns and in the transform tab click Unpivot Columns. This is what you will get

不显示数据

Notice that the time column is now renamed and there is a new colunm "value".Now select your resource column and click on Pivot column (Transform tab). For Values Column, choose Value(the new column that was added) . In advanced options, make sure "Sum" is selected.

选项

Click OK . you should have your result. In the Home tab click close and Load.

最后

The rows may not be in the correct order, coz you are using it as a string. You may use numbers for better sorting.

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