# combining 2 formulas for sub ifs

#### munozc

##### New Member
I found 2 very helpful formulas that work separately but I'm looking to find a way to combine them.

I want to calculate the subtotal of D2:D101 only if the number is greater than 0 (so no negative amounts) and if the transaction type is "SALE" for G2:G101

=SUMPRODUCT(SUBTOTAL(9,OFFSET(D2,ROW(D2:D101)-ROW(D2),0,1)),--(D2:D101>0))

=SUMPRODUCT(SUBTOTAL(3,OFFSET(D2:D101,ROW(D2:D101)-MIN(ROW(D2:D101)),,1)),--(G2:G101="SALE"),D2:D101)

if there is 1 easier way to accomplish this then that would be great too

### Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

#### Fluff

##### MrExcel MVP, Moderator
Hi & welcome to MrExcel.
Do you want to ignore hidden rows in your sum?

#### munozc

##### New Member
Hi & welcome to MrExcel.
Do you want to ignore hidden rows in your sum?
Yes. I want it to only calculate the rows that display

#### Fluff

##### MrExcel MVP, Moderator
In that case how about
Excel Formula:
``=SUMPRODUCT(SUBTOTAL(9,OFFSET(D2:D101,ROW(D2:D101)-MIN(ROW(D2:D101)),,1)),(G2:G101="SALE")*(D2:D101>0))``

#### munozc

##### New Member
In that case how about
Excel Formula:
``=SUMPRODUCT(SUBTOTAL(9,OFFSET(D2:D101,ROW(D2:D101)-MIN(ROW(D2:D101)),,1)),(G2:G101="SALE")*(D2:D101>0))``
YES!!!! THAT WORKED PERFECTLY!!! THANK YOU!

#### Fluff

##### MrExcel MVP, Moderator
You're welcome & thanks for the feedback.

Replies
2
Views
128
Replies
8
Views
1K
Replies
2
Views
316
Replies
2
Views
370
Replies
4
Views
211

1,127,723
Messages
5,626,501
Members
416,187
Latest member
L_D18

### 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?

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