How do i add year (date) criteria to DSUM? - excel

I have a database that looks like this:
(A1)Client (B1) Date (C1) debts
(A2)1 (B2) Mon 2 november 2008 (C2) 1500$
(A3)2 (B3) Thu 7 february 2008 (C3) 1000$
(A4)3 (B4) Sat 28 March 2009 (C4) 800$
(A5)4 (B5) Mon 16 March 2009 (C5) 1200$
The date format is 24/11/2008.
I have to use DSUM to get the sum of the debts clients had in 2008.
I already did a table that looks like this:
(A7)Client (A7) Date (C7) debts
(A9) 2008
and the function =DSUM(A1:C5,3,A7:C8) but it seems I can't extract the value of 2008 from the date 24/11/2008.

It is generally not a good idea to store dates as text, change your 2008 to 1/1/2008 and format as "YYYY"
To use DSUM to sum entries that fall in a calendar year you will have to define the start and end date, so your filter data will look like this:
Client Date Date
debts =">=1/1/2008" ="<1/1/2009"

Related

Excel - Sum QTD values based on selected month

Desired end state: The QTD field sums the quarterly values to date so as an example for October it would return just the October value (1st month in Q4) but when November is selected as the driver the QTD field would sum Oct + Nov values (ignoring the value for Dec).
I have a spreadsheet with drivers and the current date will be updated daily. This date drives the "Current Month" field from which I want the QTD values to recalculate.
See example linked below. Expected results - Cat 1 QTD for Nov would be 3,387,280; Cat13 QTD for April would be 1,121,021 and so on
Thanks in advance!
In O6:
=SUMIFS(C6:N6,$C$4:$N$4,"<="&MONTH("1 "&A2),$C$4:$N$4,">="&MATCH(INDEX($1:$1,MATCH(MONTH("1 "&A2),$4:$4,0)),$C1:$N1,0))
Alternative approach using SUMPRODUCT:
=SUMPRODUCT(C6:N6,--(("Q"&ROUNDUP(MONTH(1&$A$2)/3,0))=$C$1:$N$1),--($C$4:$N$4<=MONTH(1&$A$2)))
Result:

Transform text-date in format

I have a text formatted date that looks like this:
June 12th 2017, 9:07am PDT
How can I transform it in a date format (the classic methods Format Cells and DateValue() don't work)?
Thank you.
My solution uses a helper table listing all the 12 months and their serial number at A1:B12
January 1
February 2
March 3
April 4
May 5
June 6
July 7
August 8
September 9
October 10
November 11
December 12
Assuming the value is in D10
Getting the separate elements
Month:
=VLOOKUP(LEFT(D10,FIND(" ",D10)-1),A1:B12,2,FALSE)
Date:
=IFERROR(VALUE(RIGHT(LEFT(D10,FIND(" ",D10)+2),2)),RIGHT(LEFT(D10,FIND(" ",D10)+1),1))
Year:
=RIGHT(LEFT(D10,FIND(",",D10)-1),4)
Hour:
=IF(RIGHT(LEFT(D10,FIND(":",D10)+4),2)="am",RIGHT(LEFT(D10,FIND(":",D10)-1),2),RIGHT(LEFT(D10,FIND(":",D10)-1),2)+12)
Minute:
=RIGHT(LEFT(D10,FIND(":",D10)+2),2)
All this combined in the DATE and TIME function to give a single formula:
=DATE(RIGHT(LEFT(D10,FIND(",",D10)-1),4),VLOOKUP(LEFT(D10,FIND(" ",D10)-1),A1:B12,2,FALSE),IFERROR(VALUE(RIGHT(LEFT(D10,FIND(" ",D10)+2),2)),RIGHT(LEFT(D10,FIND(" ",D10)+1),1)))+TIME(IF(RIGHT(LEFT(D10,FIND(":",D10)+4),2)="am",RIGHT(LEFT(D10,FIND(":",D10)-1),2),RIGHT(LEFT(D10,FIND(":",D10)-1),2)+12),RIGHT(LEFT(D10,FIND(":",D10)+2),2),0)
Then change the format of the cell to:
mmmm dd yyyy hh:mm AM/PM "PDT"
This will give:
June 12 2017 09:07 AM PDT
To add a comma(,), use the custom format:
mmmm dd yyyy"," hh:mm AM/PM "PDT"

Find the end-of-month date from any date entered in MS Excel

I need to take the date from one cell, find the end of the month that that date falls into, then add one calendar month.
Example:
Enter jan 13: jan 13 end of month is Jan 31, + 1 month is Feb 28 (or 9 on leap year).
Feb 19: = March 31
March 2 = 30 April
March 30 = 30 April
March 31 = 30 April
etc etc
Is there an excel formula that will do this? I don't want any macro/ VBA stuff.
If you have 2007 or later than:
=EOMONTH("3/30/2016",1)
Use the Date function, add one to the month and set the Day to zero. This gives the last day of the month. To get the last day of the next month add two to the month.
=DATE(YEAR(E3),MONTH(E3)+1,0)
=DATE(YEAR(E3),MONTH(E3)+2,0)

Excel: Value from one cell based on max value with multiple criteria in other column

I am trying to get value in column 8, based on MAX value (column Range4) with multiple criteria (Range1, Range2, Range3), but excel gives me an error "#N/A". Where is the mistake?
VLOOKUP(MAX(IF(Range1=2013;IF(Range2="april";IF(Range3="Alexa";Range4))));Range5;8;FALSE)
The part
{MAX(IF(Range1=2013;IF(Range2="april";IF(Range3="Alexa";Range4))))}
works right alone (it gives me the right value), but not inside the VLOOKUP function.
Thanks!
Sample data set for testing:
First_day Last_day Week_Num Week_Range Month Year Rank_name Rank_value
01/04/2013 07/04/2013 14 1-7 april april 2013 Alexa 10122
08/04/2013 14/04/2013 15 8-14 april april 2013 Alexa 9670
15/04/2013 21/04/2013 16 15-21 april april 2013 Alexa 9130
22/04/2013 28/04/2013 17 22-28 april april 2013 Alexa 8340
29/04/2013 05/05/2013 18 29-5 april april 2013 Alexa 7543
31/03/2014 06/04/2014 14 31-06 april april 2014 Alexa 11428
07/04/2014 13/04/2014 15 07-13 april april 2014 Alexa 7159
14/04/2014 20/04/2014 16 14-20 april april 2014 Alexa 7027
21/04/2014 27/04/2014 17 21-27 april april 2014 Alexa 6675
28/04/2014 04/05/2014 18 28-04 april april 2014 Alexa 5379
Equivalence between ranges and columns:
Range1 = Column "Year"
Range2 = Column "Month"
Range3 = Column "Rank_name"
Range4 = Column "Week_Num"
Range5 = Column "Rank_value"
Please try:
=INDEX(Range8;MATCH(MAX(IF(Range1=2013;IF(Range2="april";IF(Range3="Alexa";Range4))));Range4;0))
with Control+Shift+Enter.
The problem with the existing formula (from pnuts, Jun 10 2014) is this:
The formula first narrows the list down by the nested if's, and then picks the maximum Week_Num from those rows that match your criteria. But having located that maximum, the MATCH function then ignores the criteria (they were only used to find the max from Range4). If you have other rows (even though they don't match the criteria) that have the same Week_Num, MATCH will locate the first row out of the whole list that has the same Week_Num in Range4. One solution is to add the same criteria to the MATCH's "lookup_array" that were used in the "lookup_value".
=INDEX(Range8;MATCH(MAX(IF(Range1=2013;IF(Range2="april";IF(Range3="Alexa";Range4))));IF(Range1=2013;IF(Range2="april";IF(Range3="Alexa";Range4)));0))
Again, using Control-Shift-Enter.
I think I entered the above formula correctly, but I didn't build a sheet to test it, so...
Also, be aware, this formula still has a problem in the case where no rows in the list meet the criteria. In that case you get an error. The solution to that is to add an IFERROR at the front of the whole thing.
=IFERROR(INDEX(Range8;MATCH(MAX(IF(Range1=2013;IF(Range2="april";IF(Range3="Alexa";Range4))));IF(Range1=2013;IF(Range2="april";IF(Range3="Alexa";Range4)));0)),"")

Excel Doc Sum row b where row a in between dates

I have a google spreadsheet having data as below
Date SomeVal
Aug 01, 2013 1
Aug 02, 2013 5
And so on. I want to have another sheet with Monthly grouping as follows(This is what I want in the end but unable to get here)
Month Total
Apr 2013 200
May 2013 300
I tried following but could not get correct result
=SUMIFS(Sheet1!B:B,Sheet1!A:A,ʺ> Aug 1, 2013ʺ) //Returns SUM(B:B) as all dates are above Aug 1 2013
=SUMIFS(Sheet1!B:B,Sheet1!A:A,ʺ< Jun 1, 2014ʺ) //Returns 0 which is wrong
This is what I expected to get
sum for which date > Aug 2013
sum for which date < Jun 2014
My date format is Mon DD, YYYY
Any idea Where I am wrong
This format works for me
Raw Data in Sheet2
(Column A) (Column B)
Date Val
----------- ---------
7/1/2013 1
7/2/2013 2
7/3/2013 3
7/4/2013 4
And so on and so forth up until 2/9/2016 (as long as they are date values you can format them however you want)
Summed Data in Sheet1
(Column A) (Column B)
Month Total
---------- ---------
Jul 2013 496
Aug 2013 1457
Sep 2013 2325
Oct 2013 3348
Nov 2013 4155
So on and so forth for each month that I want, using this formula. Each month is formatted as MMM YYYY, and the date is the first of the month (7/1/2013, 8/1/2013, etc...)
=SUMIFS(Sheet2!$B:$B,Sheet2!$A:$A,">="&Sheet1!$A2,Sheet2!$A:$A,"<"&Sheet1!$A3)
This says
Sum the range in Sheet 2 Column B where:
The date in column A of that row is greater than the first of the month supplied
The date in column A of that row is less than the first of the month afterwards

Resources