How to sum values based on same date and name - excel

I am trying to sum up Excel cells if they have the same date and name. In my case the column P is what I want to sum up. Column B is the date and column A is the name. Below is my attempt but it's not working. This formula works if I have ">=" but I want it calculate for specific day
=SUMIFS($P$4:$P$1000,$B$4:$B$1000,">="&Q2,$A$4:$A$1000, "="&R2)

If hte dates in column B are actually datetimes then you will have to bracket the date period just as if it was multiple days. Use >= for the start point and < start date plus 1 for the termination.
=SUMIFS($P$4:$P$1000, $A$4:$A$1000, $R$2, $B$4:$B$1000, ">="&INT(Q2), $B$4:$B$1000, "<"&INT(Q2)+1)
  
To guard against Q2 being a datetime as well, the INT function has been applied to strip off any time portion.

Related

How to assemble Offset function with Condition?

I Have date data in Column A and values data in Column B.
My aim goal is that for each date in column A :
look if one value (column B) during 1 year is less than 90% of the corresponding Value of the date.
This is my data:
Output example :
I start at the first date (31/12/1986) and see the 900.82 value.
I calcul 900.82 * 0.9 = 810.73
So i look if value in line 3 is inferior to 810.73,
If not
I look if value in line 4 is inferior to 810.73,
line 5, 6, 7 ,8..... during 1 year (that mean I stop this the 31/12/1987).
If it is
I stop and i look the next date (01/01/1987) and do the same.
I am agree to translate it in VBA code, but it could be better on Excel.
I first tried an algo to understand the problem :
-Look the first date in column A
-Look the corresponding value in Column B and save it as Value
-Offset to the next date in column A
-Look the corresponding value in Column B and save it as Range.to.compare
-If Range.to.compare < Value * 90% then write "ok" in Column C
-Else, Offset to the next date in column A...
-Untill 1 Year (Untill Year(Date in Column A)<Year(Date in Column A) +1
I try to translate it in Excel or VBA.
This this what I tried by Excel :
But it works only for 1 day instead of 1 year
I think this is what you're after. I broke the calculation into multiple columns to show the steps.
First I calculate the 90% value, in column C.
Column D is where most of the magic happens. In column D I find all rows that have a date < the current date + 1 year, and get the value (Col B) for each of those rows. I then take the minimum of all those values. Note this is an array formula so you need to press shift-ctrl-enter after you type it in.
Now that I have the minimum from the each range, I just need to compare that with the 90% value.

Excel - how to get if a date is a specific day of the week?

I have a spreadsheet that tracks average file processing times over the course of a month. One of the macros and stats that we like to pull, is performance on Mondays (as the files are a little built up over the weekend). The spreadsheet is organized into columns by weekdays of the month:
The dates are formatted MM/DD/YYYY, so I would think Excel has a date function that it can determine weekday based on that date value.
Currently, I just have to manually tell the Macro which columns are Mondays, like so:
=AVERAGE(B20,G20,L20,Q20)
So, instead of manually, how would I get the average over the range of say, B20 to V20, only if the day of the week is Monday (the date cells are in row 1, so B1 to V1)?
To determine the weekday of a date in EXCEL use the =WEEKDAY() formula, which evaluates as 1 (Sunday) to 7 (Saturday)
e.g. If A1 contains 12/31/2016 (or 31/12/2016 if you're from where I'm from), the formual =WEEKDAY(A1) would evaluate to 7 (indicating that the last day of 2016 was a Saturday)
To apply this formula to your problem: (assuming that the dates are in row 1 and the values are in row 2)
insert a new row to hold the WEEKDAY() value (say, row 2)
in cell A2 type in =WEEKDAY(A1)
copy this formula as far right as necessary (to include all your dates)
Your average for Mondays is calculated as =AVERAGEIF(2:2, 2, 3:3)
Possibly, you can add a column called [Day Of The Week] and use the following formula to display the day.
TEXT(B4,"dddd")
Then add an 'If'statement to your result cell.
simply
=SUMPRODUCT((MOD(B1:V1,7)=2)*B20:V20)/SUMPRODUCT((MOD(B1:V1,7)=2)*1)
should give the average of all values from B20 to V20 if the corresponding cell in row 1 is a monday.
the first part sums the values of all mondays and the second part counts them (sum / count = average) ;)
If you have any questions, just ask.
If your date is in A1, you can use =Text(A1,"dddd") to determine the day of the week (it will return the name, "Monday", "Tuesday", etc.) so then you could do perhaps:
=If(text(A1,"dddd")="Monday",[do whatever],[do whatever]) (may need a helper row/column to hold the text of the weekday)
(Or use AverageIf() and use the Text() idea.)

Excel: sum the last entries at month end query

I have a list of entries on a spreadsheet with a date and a percentage score. I need help in devising a formula whereby a user can select a month end date (i.e. 31 Jan) from a drop down and the average percentage of the last 15 entries will be returned.
There may be multiple entries on the same date but only the last 15 (based on the month end date) should be used. For simplicity the entries would be input in date order.
Let me know if you require any further information.
Thank you
P
Assuming your dates are in column A, the values in column B and the dropdown in D2:
=AVERAGE(OFFSET(B1,MATCH(D2,A:A,1)-1,0,-15,1))
*For this to work, your data will need to be sorted in date order!
**Also won't work if there are less than 15 rows (I assume this wouldn't be the case anyway)

Excel - Return dates in a list that are within 1 year of another date

I'm trying to write a formula that would return a date (B) from a list if that date is within 1 year of another date (A). If there are no dates in the list that are within 1 year of date A, then date B will simply be date A plus 1 year (365.25 days).
For example: My list is [2/15/16, 12/26/17, 5/15/19]. If date A is 1/1/16, then I want Date B to equal 2/15/16. If Date A was 2/15/16, then Date B would be 2/15/17.
The closest I've gotten is:
=IF(MIN(L:L)-A<=365.25,MIN(L:L),A+365.25), but obviously this won't work beyond the minimum date. I need to check against the whole list of dates, not just the minimum date.
My end goal is to make a list like this (column A after the first date is just the previous B:
From (A) - To (B)
1/1/15 - 1/1/16
1/1/16 - 2/15/16
2/15/16 - 2/15/17
2/15/17 - 12/26/17
Thanks for any tips in advance!
If I understand correctly, this should work
=IFERROR(LOOKUP(2,1/((($A$2:$A$4-C2)<365.25)*(($A$2:$A$4-C2)>0)),$A$2:$A$4),EDATE(C2,12))
Column A has the list of dates, C2 has Date A. Running some more dates in column C, copying the formula down:

How to get the week number of the year from the date range in an Excel Pivot Table

Hi I would like to know a formula where I can convert a grouped date range into the week number of the year. For example column A has the date ranges. I want column B to have the week number. So it will be like the example below
Column A Column B
31/12/2013 - 06/01/2013............................................Week 1
07/01/2013 - 13/01/2013............................................Week 2
Thanks to anyone who can solve this. Its been bugging me out
You could perhaps use something like that:
=(RIGHT(A2,10)*1-41273)/7
This takes the last date in that date range, turns it into a number and subtracts 41273 (which is the equivalent of 1st January 2013) and divides the result by 7.
If you want to specifically get Week 1, you can either use custom formatting with "Week "#, or if you want the literal Week, you can use ="Week "&(RIGHT(A2,10)*1-41273)/7

Resources