Sum If Then formula help

Copper Contributor

I need help with a formula, I think it's going to be a If Then sum formula, but I haven't had a lot of luck trying to figure this out on my own. In my example, I want to sum the payment amount (E), if the date field (B) and the form of payment field (D) are the same. Any help would be greatly appreciated!!

 

ABCDEFG
Decatur5/2/20192019 CASH DECATURMaster Card 211905020004$376.05
Decatur5/2/20192019 CASH DECATURVisa 211905020002$253.21
Decatur5/4/20192019 CASH DECATURVisa 211905040002$170.04
Decatur5/6/20192019 CASH DECATURMaster Card 211905060002$530.71
Decatur5/6/20192019 CASH DECATURVisa 211905060001$504.67
Decatur5/7/20192019 CASH DECATURDiscover 211905070006$1,098.72
Decatur5/7/20192019 CASH DECATURDiscover 211905070007($1,098.72)
Decatur5/7/20192019 CASH DECATURMaster Card 211905070012$327.10
Decatur5/8/20192019 CASH DECATURVisa 211905080003$1,030.90
Decatur5/8/20192019 CASH DECATURVisa 211905080004$257.23
Decatur5/15/2019C&C ASPHALT INC.American Express 211905150005$284.45
Decatur5/15/2019HOOD, LARRYVisa 211905150006$561.68
Decatur5/16/20192019 CASH DECATURMaster Card 211905160002$1,340.91
Decatur5/17/20192019 CASH DECATURMaster Card 211905170003$1,526.20
Decatur5/17/20192019 CASH DECATURVisa 211905170001$1,276.19
Decatur5/20/20192019 CASH DECATURMaster Card 211905200001$378.01
12 Replies

@Jon-W ,

 

It depends on how you'd like organize the result. If like

image.png

then

=SUMIFS($G:$G,$D:$D,J$1,$B:$B,$I2)

@Sergei Baklan 

 

This is how I need to format it, this is how it looks when I just add it myself.

 

Kennesaw5/2/2019PROCONTRACTOR SUPPLY, INC.Master Card$855.00551905020002$855.00
Kennesaw5/3/20192019 CASH KENNESAWMaster Card$254.40551905030006$254.40
Kennesaw5/3/2019MAX JONESVisa$1,470.40551905030004$1,470.40
Kennesaw5/4/2019APEX SEAL COATINGSMaster Card$482.72551905040001$482.72
Kennesaw5/6/2019APEX SEAL COATINGSMaster Card$321.82551905060001$321.82
Kennesaw5/14/20192019 CASH KENNESAWVisa$281.59551905140007$281.59
Kennesaw5/15/20192019 CASH KENNESAWVisa 551905150006$58.29
Kennesaw5/15/20192019 CASH KENNESAWVisa$411.27551905150012$352.98
Kennesaw5/16/20192019 CASH KENNESAWVisa$136.21551905160005$136.21
Kennesaw5/23/20192019 CASH KENNESAWVisa$154.74551905230003$154.74
Kennesaw5/24/20192019 CASH KENNESAWVisa 551905240006$529.47
Kennesaw5/24/20192019 CASH KENNESAWVisa$618.50551905240007$89.03
Kennesaw5/28/20192019 CASH KENNESAWMaster Card$437.23551905280006$437.23
Kennesaw5/29/20192019 CASH KENNESAWMaster Card$335.23551905290002$335.23
Kennesaw5/29/20192019 CASH KENNESAWVisa$719.38551905290005$719.38

@Jon-W ,

 

And do records sorted by dates in ascending order and when by card type? Or for the same date records could be like

Visa

MasterCard

Visa

MasterCard

 

 

@Sergei Baklan 

 

They are sorted first by date, then by card type.

@Jon-W 

When it could be like in column I in Sheet2 attached

image.png

=IF(($B1=$B2)*($D1=$D2),"",SUMIFS($G:$G,$B:$B,$B1,$D:$D,$D1))

Start from row 1 and drag down

@Sergei Baklan 

 

That is EXACTLY what I need, but I'm not an Excel expert, and can't figure out how you got the formula into that whole row. When I use formulas, so far they have been basic. =A1*A2 and then I would copy and paste that formula into all the cells below it. This what I'm coming up with when I try your formula. I will paste here, and then link a copy of the excel file. And thank you so much for your help!!

 

DateCustomerNamePayment SaleNumAmount 
5/1/20192019 CASH BIRMINGHAMCash462471905010002$462.00=IF(($B2=$B3)*($D2=$D3),"",SUMIFS(#REF!,$B2:$B21,$B2,$D2:$D21,$D2))
5/2/2019B & T LABORINGCash$190.30471905020005$190.30 
5/8/20192019 CASH BIRMINGHAMCash93.5471905080006$93.50 
5/9/20192019 CASH BIRMINGHAMCash27.5471905090007$27.50 
5/13/20192019 CASH BIRMINGHAMCash 471905130002$492.80 
5/13/20192018 CASH BIRMINGHAMCash156.75471905130006$156.75 
5/15/2019WARREN ASPHALT CONSTRUCTIONCash 471905150003$8.79 
5/15/20192018 CASH BIRMINGHAMCash 471905150004$331.91 
5/15/20192018 CASH BIRMINGHAMCash 471905150006$165.54 
5/15/20192018 CASH BIRMINGHAMCash 471905150007$2.75 
5/15/20192019 CASH BIRMINGHAMCash64.89471905150008$64.89 
5/18/2019BIG JOHN'S ASPHALT PAVINGCash13.2471905180002$13.20 
5/21/20192019 CASH BIRMINGHAMCash492.8471905210002$492.80 
5/23/20192019 CASH BIRMINGHAMCash 471905230001$372.89 
5/23/20192019 CASH BIRMINGHAMCash 471905230008$367.40 
5/23/20192019 CASH BIRMINGHAMCash943.8471905230009$943.80 
5/24/20192019 CASH BIRMINGHAMCash 471905240002$243.91 
5/24/20192019 CASH BIRMINGHAMCash722.7471905240008$722.70 
5/25/2019SOUTHERN SEALS AND STRIPESCash724.9471905250002$724.90 
5/31/20192019 CASH BIRMINGHAMCash176471905310005$176.00 

@Jon-W 

 

In your case formula will be like

=IF(($A2=$A3)*($C2=$C3),"",SUMIFS($F$2:$F2,$A$2:$A2,$A2,$C$2:$C2,$C2))

Be careful which columns to take for the calculation and with absolute / relative references. 

Condition parameter in IF checks if the date AND payment method are the same in the current and next row. If so then empty string. If no, then SUMIFS calculates sum of all payments from first to current row for which the date and payment method are are the same as for current row. 

@Sergei Baklan 

 

You are a life saver!! I have one more snag, and probably something I should have mentioned earlier. In this sheet, there are multiple locations, which might have transactions on the same day for the same form of payment. I have 4 locations, the formula you gave works perfect for the first store, but on the second store, it starts to add the totals from the first store.

This is your formula

=IF(($B1=$B2)*($D1=$D2),"",SUMIFS($G:$G,$B:$B,$B1,$D:$D,$D1))

 

This is your formula, tweaked for my sheet, that does work on the different categories for my first store

=IF(($B2=$B3)*($D2=$D3),"",SUMIFS($G$2:$G2,$B$2:$B2,$B2,$D$2:$D2,$D2))

 

This is what I came up with when I tried to add a 3rd condition

=IF(($B2=$B3)*($D2=$D3)*($A2=$A3),"",SUMIFS($G$2:$G2,$B$2:$B2,$B2,$D$2:$D2,$D2))

 

That still worked for the first location, but then added the daily total from the store above.

 

Once again, I appreciate the help so much!!

@Sergei Baklan 

 

Any thoughts? You have been such a help so far!!

@Jon-W 

 

Sorry, I missed your question. That could be

=IF($A2="","",IF(($B2=$B3)*($D2=$D3)*($A2=$A3),"",SUMIFS($G$2:$G2,$B$2:$B2,$B2,$D$2:$D2,$D2,$A$2:$A2,$A2,$A$2:$A2,"<>")))

in cell E2 and drag it down till end of the range over all locations.

@Sergei Baklan 

 

You are THE BEST!! Thank you so much for your help!!

@Jon-W 

 

You are welcome, glad to help