Nested subtraction in SUMIFS

filido

New Member
Joined
Jun 7, 2019
Messages
21
Hi,

I'm trying to populate a formula that sums all the sales of a particular item with few conditions:

=SUMIFS(Table1[Sales New] - Table1[Sales Change]; Table1[Sales New] - Table1[Sales Change];">0";Table1[Sales New];">0";Table1[Item];"Blue shirt")

--> Table1[Sales New]-Table1[Sales Change] = Old Sales of the blue shirt
--> Table1[Sales New] = New Sales of the blue shirt
--> Table1[Item];"Blue shirt" = Find item "Blue shirt" from list of items

So this is what I want: SUM all blue shirts' Old Sales, IF Old Sales AND New Sales are both over 0.

Excel however says that there's an error with this formula. Any thoughts?

I know I could get around this by creating a column for Old Sales but for the sake of the file size, I want to keep the number of columns as minimum as possible.

I also tried this: Table1[Price Old] * Table1[Quantity] to get the old sales but this also caused an error.

=SUMIFS(Table1[Price Old] * Table1[Quantity]; Table1[Price Old] * Table1[Quantity];">0";Table1[Sales New];">0";Table1[Item];"Blue shirt")

Thanks in advance!
 

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
7,793
Office Version
365
Platform
Windows
Sumifs only accepts ranges for its sum ranges and criteria ranges. You would have to use sumproduct to do subtraction.

=SUMPRODUCT((Table1[Sales New] - Table1[Sales Change]),--((Table1[Sales New] - Table1[Sales Change])>0),--(Table1[Sales New]>0),--(Table1[Item]="Blue shirt"))
 

filido

New Member
Joined
Jun 7, 2019
Messages
21
Hi,

That formula returns #N/A. Is the formula affected if e.g. some sales of the blue shirt is #N/A? Below is an example data:

DateShirtSales NewSales Change (from last year)
MondayBlue shirt22+2
MondayWhite shirt25-5
TuesdayBlue shirt#N/A#N/A
WednesdayBlue shirt15+5
WednesdayRed shirt200

<tbody>
</tbody>

Because Tuesday's blue shirt data is unavailable, is my SUMPRODUCT formula affected by it and causes the formula to return #N/A?

If #N/A doesn't affect the SUMPRODUCT, what else might be the problem?
 

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
7,793
Office Version
365
Platform
Windows
Yes you will have to correct the n/a for all entries in the column. Use an iferror formula. You could also do with using the same headers as you suggested in post 1.
 

Forum statistics

Threads
1,082,360
Messages
5,364,920
Members
400,815
Latest member
Joaquin Phoenix

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top