简体   繁体   中英

Index and match with multiple criteria

I have a database of hourly data for an entire year. I want to find the 98th percentile for NO2 (for example) for each hour for each season (Dec-Jan-Feb, Mar-Apr-May, etc.)

I'm trying to use MATCH and INDEX to find the cells for one hour for one season.

=INDEX(A1:E8985,MATCH(Z2,(C3:C8985=AA2,AA3,AA13)*(B3:B8985=Z2),0))

where A1:E8985 is the table area I'm looking in

Z2 is the hour (1:00), looking in column B, which contains the hours

AA2,AA3,AA13 are January, February, and December (one season), looking in column C, which contains the months.

Right now, I'm getting an #N/A error even though the criteria should be met multiple times. I have made sure that the columns match formats.

Sample of part of the table:

Date    Time        Month        NO     NO2

1/1/2016    1:00    January -0.1    0.2
1/1/2016    2:00    January -0.1    0.1
1/1/2016    3:00    January -0.1    0.1
1/1/2016    4:00    January -0.1    0.2
1/1/2016    5:00    January -0.1    0.2
1/1/2016    6:00    January -0.1    0.4
1/1/2016    7:00    January -0.1    0.3
1/1/2016    8:00    January -0.1    0.8
1/1/2016    9:00    January -0.1    0.5
1/1/2016    10:00   January -0.1    0.2
1/1/2016    11:00   January -0.1    1.3
1/1/2016    12:00   January -0.1    0.7
1/1/2016    13:00   January -0.1    0.4
1/1/2016    14:00   January 0   0.7
1/1/2016    15:00   January -0.1    0.5
1/1/2016    16:00   January -0.1    0.4
1/1/2016    17:00   January -0.1    1
1/1/2016    18:00   January -0.1    0.7
1/1/2016    19:00   January -0.1    0.9
1/1/2016    20:00   January 1.6 4.5
1/1/2016    21:00   January 2.8 6
1/1/2016    22:00   January 0.1 1.1
1/1/2016    23:00   January 0.2 1.3
1/2/2016    0:00    January 0.2 1.4

Let me summarize the logic you want, you want the 98 percentile of NO2 where the month is either January, February or December and the value of time is 1:00, then for 2:00 and so on.

If it is so find below the formula applied only to the current data you have provided.

Note that it is an array formula

=PERCENTILE.INC(
    IF(C1:C25="January",
        IF(B1:B25=Z2,
            E1:E25,
            ""),
        IF(C1:C25="February",
            IF(B1:B25=Z2,
                E1:E25,
                ""),
            IF(C1:C25="December",
                IF(B1:B25=Z2,
                    E1:E25,
                    ""),
                ""))
    ),0.98)

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