Excel formua like SUMIFs with criteria in different tables

时间:2017-12-18 05:49:47

标签: excel

I don't know if I am missing something obvious or what, but I cannot wrap my brain around what I need from this. I have a table with products available for sale and various criteria. I have a second table with a smaller list of stores and a second column of whether I should include them in my results set. In this example, I would never include store 789, but I might include 123 and/or 456, depending on whether an "x" was placed in that second column.

So, for my results, I would break them out by Product and color with a simple SUMIFS statement. However, I really want to be able to filter the sites out if they are "x" on that second tab. Any thoughts on how I could easily do that? I did insert a column on my raw data sheet and just added an if statement, then I used that as a 4th criteria in my SUMIFS, but I was looking for a more elegant solution.

I can get either matching stores or the rest of the filters, but I cannot figure how to make both work together in the same statement or how to include them if they are "x"-ed.

This will get me the filtered stores

=SUMPRODUCT(SUMIF('Tab1'!A:A,'Tab2'!A:A,'Tab1'!D:D))

Either of these will get me the filtered products:

=SUMIFS('Tab1'!D:D, 'Tab1'!B:B, A2, 'Tab1'!C:C, B2)
=SUMPRODUCT(--('Tab1'!B:B=A2), --('Tab1'!C:C=B2), 'Tab1'!D:D)

Tab1

Store | Product | Color | Sales
--------------------------------
 123  |  A      | Red  |   1
 123  |  A      | Blue |   2
 123  |  B      | Red  |   4
 456  |  A      | Blue |   8
 456  |  B      | Red  |   16
 789  |  A      | Red  |   32
 789  |  B      | Red  |   64

Tab2

Store | Include
---------------
 123  |       
 456  |  x     

Results:

Product | Color | Sales
------------------------
  A     | Red   |   0
  A     | Blue  |   8
  B     | Red   |   16

2 个答案:

答案 0 :(得分:0)

Why not use VLookUp's to add the column from Tab2 to Tab1?

For example, new Column E, to the right of Sales:

=VLookUp(A1, "Tab2", 2, False)

...and fill-down?

You could base SumIf criteria on multiple tables but personally I'd just keep the data together (dynamically) just to make it easier and neater.

答案 1 :(得分:0)

Build a pivot table and use slicers to include or exclude specific data. Then you don't need a helper table and you don't need formulas, either. Just a few clicks.

enter image description here