Excel Formula For Calculating If Two Cells Equal Criteria Then Sum The Cells Next To The Line - excel-formula

I'm currently trying to create a formula that will look at two columns for a criteria and then sum up the cells next to it,
For example,
Column A Column B Column C
Date Range Type Value
01/01/2018 Credit £4.00
02/01/2018 Debit £4.00
05/01/2018 Credit £6.00
01/02/2018 Debit £5.00
01/03/2018 Credit £6.00
What i want the formula to do is look at column A for if it is greater or equal to the current month and column B equals credit, then calculate and add the cells together, so for the above example the answer would be the credit for the month,
So for the month of January the answer would be £10
So far i have tried:
=SUM(IF((W7:W28<=X1)+(X7:X28=AA2),Y7:Y28,0))
But this just does the SUM for all cells in the array
Tried:
=SUMPRODUCT(W7:W28>=X1 * X7:X28=AA2 *Y7:Y28)
But this just gives me a VALUE error unfortunatly :(
Can you please advise how i can create a formula to do a SUMIFS but with an array and equal to this month

Try the following for a January SUM:
=SUMIFS(C2:C6,A2:A6,">="&"01-Jan-2016",A2:A6,"<"&"01-Feb-2018",B2:B6,"=Credit")
The SUMIFS function is of the format:
SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)
So we tell the system to sum across C2:C6 but only when
A2:A6,">=" & "01-Jan-2018" : the value in the A column is greater than 01-Jan
A2:A6,"<" & "01-Feb-2018" : the value in the A column is less than 01-Feb
B2:B6,"=Credit" : the value in the B column equals the string "Credit"
Hope this helps.

Related

Count cell per month

I look for a code for the number of times a value is in a cell, on a monthly basis
So
1-1-19 KS
2-1-19
3-1-19 KS
.
.
1-2-19 KS
2-2-19
3-2-19
January 2
February 1
is this possible?
Assume that your dates are in column A, your KS is in column B.
In cell D1:D12 you have the first of each month entered and given a custom number format of mmmm so it just shows January, February, etc.
The formula =MATCH($D1,$A:$A,0) will give the row number that the month starts on.
For simplicity I'll call this Start_Row.
The formula =MATCH(EOMONTH($D1,0),$A:$A,0) will give the row number that the month ends on.
I'll call this End_Row.
The formula INDEX($B:$B,Start_Row):INDEX($B:$B,End_Row) will set a reference in column B to all rows between the first of the month and the end of the month.
I'll call this CountRange.
Now you just need to count what's in that reference using either:
=COUNTIF(CountRange,"KS") to count just KS
=COUNTA(CountRange) to count any non-blank cells.
So the full formula, without any helper columns, would be:
=COUNTIF(INDEX($B:$B,MATCH($D1,$A:$A,0)):INDEX($B:$B,MATCH(EOMONTH($D1,0),$A:$A,0)),"KS")
Keeping in mind that D1 contains 01/01/2019

Excel AverageIf to get total average of multiple rows from a table

I have provided a simple example of what I would like to do. I tried to use AverageIf to get the average of all Monday sales for March and April but the formula only provides me the average of March's Monday sales and excludes April.
Note: Column A is Weekday number, Column B is March Sales, Column C is April Sales.
This is the formula I used:
=AVERAGEIF(A2:A200, "=" & 1, B2:C200), which only provides me with average Monday sales in column B.
How can I adjust the formula to also include April in the total average (i.e. take into account column C rather than just column B alone)
Rather than using AverageIf(), try using Average(If()) as an array formula for this kind of scenario.
In your scenario, you could use the following formula to get the average:
=AVERAGE(IF(A2:A200=1,B2:C200))
ENTERED AS AN ARRAY FORMULA using cntrl + shift + enter
Hope that helps.

Sum with dynamic condition

I have an Excel file in which some columns. The Excel is my bank account.
The D column is date, and not just for one day,its the days of a week.
I want to some all columns in that has the same date, and insert it in new cell.ex : for a week i should have 7 sum.
Here is some possible data from the sheet.
date(Column D) Money(Column K) Sum of same date(Column N)
1396/1/1 2300
1396/1/1 1000 3300 // some of the same date
1396/1/2 1200
1396/1/2 320 1550 // some of the same date
It is possible with Excel functions? Does I need a subroutin?
In L2 try,
=IF(ROW()=MATCH(D2, D:D), SUMIFS(K:K, D:D, D2), TEXT(,))
Fill down.
Use this formula:
=IF(D2<>D3,SUMIF(D:D,D2,K:K),"")
Then copy down
Hey you need to work with Sumif or SUMIFS and your Formula should like,
SUMIFS(D2:D10, C2:C10,">="&TODAY()-7, C2:C10,"<="&TODAY())
Or it should be like,
=SUMIFS(D2:D10, C2:C10,">="&A2, C2:C10,"<="&A3)
Or
=SUMIF(D2:D10, C2:C10,">="&TODAY())
NB: Sum Range is D2:D10 & C2:C10 is Criteria range.
In 2nd example A2 & A3 Cells holds Date value.
Suppose your Dates are in Col A & you want to Sum values in Column B, so instead of Sumif you can use this,
C2=SUMPRODUCT(--(MONTH(A$2:A$10)=ROW()-1),--(B$2:B$10))
NB: MONTH function will pull the Month value from A2 and add with corresponding Cell value in B, drag the formula below.

Excel SUMIFS Statement - Calculate profit for each month across multiple years

I've got three columns of data.
Sell Date - Column G - Contains the day, month and year in dd/mm/yyy format.
Month (calculated from sell date) - Column I - Contains month number
Profit - Column M - Profit in Dollars.
I am trying to calculate the profit made in each month and year.
Current formula using SUMIFS. I look at the data in Column I and if this contains a 1, and if G contains the year 2016 then it's January 2016. Think it's the year function that I don't quite get.
=SUM(SUMIFS(M9:M50, I9:I50, {"1"}, G9:G50, YEAR=2016))
You can create another column that shows just the year year(G2) or you can use this formula
=SUMIFS(M9:M50,G9:G50,">=1/1/2016",G9:G50,"<1/2/2016")
I also like this formula that allows you to reference the date in one cell and calculate a 1 month range. Put 01/01/2016 in cell A1 and the formula does the rest.
=SUMIFS(M9:M50,G9:G50,">="&A1,G9:G50,"<" & EDATE(A1,1))
The SUMIFS function doesn't like it when you alter the value of the IF parameters. It would be better to use a SUMPRODUCT formula to calculate this, for example:
=SUMPRODUCT((M9:M50)*(I9:I50=1)*(YEAR(G9:G50)=2016))
Where:
(M9:M50) are the values you wish to SUM.
(I9:I50) are the month values and 1 is the month you wish to specify.
(G9:G50) are the date values you wish to obtain the year from and 2016 is the year you are specifying.

Excel Countif using month and letter as Criteria's

I have a list of sales data that includes the date of the sale and also a sales type code. I'm trying to use COUNTIFS to count how many sales of a specific type there were during each month .
So for example:
Date. Sales Type Code
10/01/2014. S
12/01/2014. S
15/01/2014. O
18/01/2014. S
02/02/2014. O
08/02/2014. S
Would give me the following results:
Code S
January - 3
February - 1
Code O
January - 1
February - 1
I have the formula
COUNTIFS('SALES LEDGER'!A:A,F2,'SALES LEDGER'!C:C,"<"&EOMONTH('MONTH Sales by Sales Type'!$C$1,0)+1)
Where A:A is the list of Sales Type Codes, F2 is the code I want to count, C:C is the list of dates and C1 is the first of the month I want to count (ie. 01/01/2014).
This works fine for January, giving me the expected result. But when I change C1 to 01/02/2014, it counts January and February together, rather than just February.
If anyone has any suggestions it would be appreciated!
Thanks
Your COUNTIFS formula specifies an end date but no start date, if you want to count for a specific month and year (based on C1) you need another criterion to specify the start date using C1, i.e.
=COUNTIFS('SALES LEDGER'!A:A,F2,'SALES LEDGER'!C:C,"<"&EOMONTH('MONTH Sales by Sales Type'!$C$1,0)+1,'SALES LEDGER'!C:C,">="&'MONTH Sales by Sales Type'!$C$1)
You could use this one (if your range with dates doesn't contain empty cells):
=SUMPRODUCT((MONTH(A2:A100)=1)*(B2:B100="S"))
or (if your range could contain empty cells)
=SUMPRODUCT((TEXT(A2:A100,"mmm")="Jan")*(B2:B100="S"))
If you need to add also year condition, just add *(YEAR(A2:A100)=2014) in any formula:
=SUMPRODUCT((TEXT(A2:A100,"mmm")="Jan")*(YEAR(A2:A100)=2014)*(B2:B100="S"))
Assuming:
it is amenable to use helper columns
Dates in col A
Sale Type Codes in col B
Results placed from A9:C11
Screenshot:
Add a helper col C to extract Month from date. Add this formula in C2 and drag down:
=TEXT(A2,"Mmm")
Add this formula in B10 and drag down and across:
=COUNTIFS($B$1:$B$7,B$9,$C$1:$C$7,$A10)
with the code below you can retrieve the month each date is in:
dim objDate as Date
dim i as integer
dim intMonth as integer
for i = 2 to 'number of row
objDate = CDate(cells(i, 1))
intMonth = Month(objDate)
next i
After figuring out the month with a simple loop you can count the number of sales in each month.

Resources