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!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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"))
 
Upvote 0
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:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Date[/TD]
[TD]Shirt[/TD]
[TD]Sales New[/TD]
[TD]Sales Change (from last year)[/TD]
[/TR]
[TR]
[TD]Monday[/TD]
[TD]Blue shirt[/TD]
[TD]22[/TD]
[TD]+2[/TD]
[/TR]
[TR]
[TD]Monday[/TD]
[TD]White shirt[/TD]
[TD]25[/TD]
[TD]-5[/TD]
[/TR]
[TR]
[TD]Tuesday[/TD]
[TD]Blue shirt[/TD]
[TD]#N/A[/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]Wednesday[/TD]
[TD]Blue shirt[/TD]
[TD]15[/TD]
[TD]+5[/TD]
[/TR]
[TR]
[TD]Wednesday[/TD]
[TD]Red shirt[/TD]
[TD]20[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]

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?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top