# 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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

#### 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
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
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
5
Views
93
Replies
2
Views
134
Replies
8
Views
1K
Replies
2
Views
330
Replies
2
Views
377

1,129,825
Messages
5,638,545
Members
417,034
Latest member
Jigneshbharati

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

### Which adblocker are you using?

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

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