简体   繁体   中英

EXCEL Sum range based on row and column criteria

Given the Category table below:

样本

... how can I add all values in a particular category row that are in columns where the date header is <= TODAY()?

For example, in cell B2 I want a running total of the values corresponding to the "Internet Bill" row and only columns where today (3/15) is >= the date in the column header. I highlighted these values in red just for the example.

Here's what I have so far in B2:

=SUM(INDEX($F$2:$J$4,MATCH($A2,$E2,0),MATCH(TODAY(),$F$1:$J$1,1)))

But it's only giving me "$45," which I understand correlates the greatest date value lesser than 3/15. I just can't get the INDEX formula to return a column_num range filtered by a comparison operator...

B2 G$1:J$1 requires date format, please change J1 to your actual range.

=SUM(OFFSET(F$1,MATCH(A2,E:E,)-1,,,COUNTIF(G$1:J$1,"<="&TODAY())))

Assuming you have office 365, you can use the formula below

=IFERROR(SUM(FILTER(FILTER($B$3:$N$4,$A$3:$A$4=B7),$B$2:$N$2<=$A$1)),"Not Found")

样本数据和结果

The formula also accounts for error supposing the data is not found

Supposing your data table is in another Sheet (Sheet 1), you can use formula below

=IFERROR(SUM(FILTER(FILTER(Sheet1!$B$3:$N$4,Sheet1!$A$3:$A$4=B2),Sheet1!$B$2:$N$2<=$A$1)),"Not Found")

样品 2

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