Sum with dynamic condition - excel

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.

Related

Number occurrences in another cell (Excell) [duplicate]

I have simple problem, but I've not be able to get an answer from searching. I require a column to calculate the number of the nth occurrence of a value. It's best explained in this picture
I require a method to calculate column B.
I'd be very grateful for any help.
Are you looking to merely provide a count of the distinct entries of column A in column B? Or merely add a formula to come up with the table in your link?
If the latter, then the formula to write in cell B2 is:
=COUNTIF(A$2:A2,A2)
then copy/paste it down column B. Note - if your data is both a Date and Time, but the cell is formatted to only display a date, you may not get the results you want. You'd need to interject a new column with a "floor" calculation to round the date/time value to a date (Excel date times are decimal, with integer part dictating the date, and remaining 0.0 -> 1.0 dictating the time of day)
If you just want to derive a table of the counts of distinct entries in column A, then a pivot table will do this for you - simple add a pivot table to cover the data in column A, then select column A into the rows category, and then also drag it into the values category, ensuring the field is set to "Count of". You should then have a table with the distinct entries in your data set in one column, and the count of their occurrences in the other column.
You can use the COUNTIF worksheet function, with a relative address.
Eg. In cell B2, enter this formula:
=COUNTIF(A$2:A2,A2)
And then fill-down.
Use the following formula to generate the required series:
=COUNTIF($A$1:A1,A1) and strech(copy) it in all the cells
This will generate result like this:
A 1 COUNTIF($A$1:A1,A1)
A 2 COUNTIF($A$1:A2,A2)
C 1 COUNTIF($A$1:A3,A3)
C 2 COUNTIF($A$1:A4,A4)
B 1 COUNTIF($A$1:A5,A5)
B 2 COUNTIF($A$1:A6,A6)
A 3 COUNTIF($A$1:A7,A7)
C 3 COUNTIF($A$1:A8,A8)
D 1 COUNTIF($A$1:A9,A9)
D 2 COUNTIF($A$1:A10,A10)
D 3 COUNTIF($A$1:A11,A11)
D 4 COUNTIF($A$1:A12,A12)

VLOOKUP between two dates

I 'd like to lookup in which period a date falls. Every period has its onwn name.
In my first sheet I have a list of dates:
4/03/2019
15/01/2019
15/01/2019
20/02/2019
11/02/2019
11/02/2019
In an other sheet I have the name with the corresponsing start and end date:
NAME START END
A1 12/01/2019 22/01/2019
A2 23/01/2019 8/02/2019
B 9/02/2019 13/02/2019
C1 14/02/2019 1/03/2019
C2 2/03/2019 5/03/2019
C3 6/03/2019 15/03/2019
I would like to have the following result
4/03/2019 C2
15/01/2019 A1
15/01/2019 A1
20/02/2019 C1
11/02/2019 B
11/02/2019 B
Use INDEX/MATCH Like this:
=INDEX(E:E,MATCH(A1,F:F))
You can try this:
I suppose that your dates are in a sheet named "dates"
And you have your data in other Sheet
You can easly get your result with the following formula:
=INDEX(Sheet12!A:C,MATCH(dates!A2,Sheet12!B:B,1),1)
I hope this helps!!!
You don't even need the end date, as your dates are increasing
=VLOOKUP(D1,$A$1:$B$6,2,TRUE)
where D1 is the date you're matching A is the start date and B your codes
What about using INDEX & MATCH? Example below:
[Assuming your first set of data is in column A, and the formula would be in column B on Sheet1, and your second table is columns A:C in Sheet2. So the example in your third table would have "C2" in column B]
Note: You'll need to use Ctrl+Shift+Enter to enter as an array formula.
=INDEX(Sheet2!$A$2:$A$7,MATCH($A2,IF($A2>=Sheet2!$B$2:$B$7,IF($A2<=Sheet2!$C$2:$C$7,$A2)),0))
Are the date ranges set to expand further beyond a static list or are they set. Because if they are set i would be tempted to do a nested IF statement. I can explain if this is the case.
IF("date cell"<=latest date,code,If("date cell"<= next latest, If( repeat until happy

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

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.

Calculate Occurrence Number - Excel

I have simple problem, but I've not be able to get an answer from searching. I require a column to calculate the number of the nth occurrence of a value. It's best explained in this picture
I require a method to calculate column B.
I'd be very grateful for any help.
Are you looking to merely provide a count of the distinct entries of column A in column B? Or merely add a formula to come up with the table in your link?
If the latter, then the formula to write in cell B2 is:
=COUNTIF(A$2:A2,A2)
then copy/paste it down column B. Note - if your data is both a Date and Time, but the cell is formatted to only display a date, you may not get the results you want. You'd need to interject a new column with a "floor" calculation to round the date/time value to a date (Excel date times are decimal, with integer part dictating the date, and remaining 0.0 -> 1.0 dictating the time of day)
If you just want to derive a table of the counts of distinct entries in column A, then a pivot table will do this for you - simple add a pivot table to cover the data in column A, then select column A into the rows category, and then also drag it into the values category, ensuring the field is set to "Count of". You should then have a table with the distinct entries in your data set in one column, and the count of their occurrences in the other column.
You can use the COUNTIF worksheet function, with a relative address.
Eg. In cell B2, enter this formula:
=COUNTIF(A$2:A2,A2)
And then fill-down.
Use the following formula to generate the required series:
=COUNTIF($A$1:A1,A1) and strech(copy) it in all the cells
This will generate result like this:
A 1 COUNTIF($A$1:A1,A1)
A 2 COUNTIF($A$1:A2,A2)
C 1 COUNTIF($A$1:A3,A3)
C 2 COUNTIF($A$1:A4,A4)
B 1 COUNTIF($A$1:A5,A5)
B 2 COUNTIF($A$1:A6,A6)
A 3 COUNTIF($A$1:A7,A7)
C 3 COUNTIF($A$1:A8,A8)
D 1 COUNTIF($A$1:A9,A9)
D 2 COUNTIF($A$1:A10,A10)
D 3 COUNTIF($A$1:A11,A11)
D 4 COUNTIF($A$1:A12,A12)

How do I specify a criteria that compares dates in Excel's SUMIFS function?

I'm using Excel 2010, which includes the SUMIFS function. My spreadsheet is in this format:
A B C
Date Amount Category
01/01/2013 $20.00 CatA
01/12/2013 $35.67 CatB
02/04/2013 $16.98 CatA
etc. In another part of the spreadsheet, I have these cells:
X Y
1 CatA_header
2 Jan-13 formula...
3 Feb-13
4 Mar-13
I'd like to place a formula in the cell specified by formula... (in cell Y2) that sums column B for the given category and the given year/month combination. I thought SUMIFS was right for the task, so I tried this formula:
=SUMIFS(B:B, A:A, AND(MONTH(A:A)=MONTH(X2), YEAR(A:A)=YEAR(X2)), C:C, "="&Y1)
However, this returns 0, even though it should return 20 in my contrived example. How can I use the SUMIFS function to perform this task?
Your row numbers seem to be off by 1, e.g., Y0. Also, you can't filter the criteria range like that, I don't think. Here's a SUMPRODUCT that works on rows 2 to 10:
=SUMPRODUCT(($B$2:$B$10)*(MONTH($A$2:$A$10)=MONTH(X2))*(YEAR($A$2:$A$10)=YEAR(X2))*($C$2:$C$10= Y$1))

Resources