What function do I need for getting year-to-date % increase over prior year? - excel

I have an excel workbook for multiple restaurants that has sheets for every year labeled with their sales per month. I am attaching an example of one row of the sheet for the year 2020. I would like to have a cell at the end of each row that shows the % increase or decrease over the prior year up to the last month entered. It would be pulling the information for the results from the prior sheet. I don't know which function to use or how to get the function to only add the corresponding months to date from last year. For example, on the sheet for 2020, sales are listed through July but the sheet for 2019 has all 12 months listed. I would like to include a cell that gives me the year-to-date % through whatever current month it is.
Sheet for Year 2020

If you want to use only the columns filled in the current year in the percentage calculation, you can use following formula:
=SUM(B3:M3)/SUMPRODUCT(B2:M2*(B3:M3>0))-1

First count how many cells are blank in your current year using the
=COUNTBLANK()
Then sum up the year you are comparing to starting at january then going 12 - result of blankcells formula to the right.
=SUM(OFFSET(JANUARY_CELL_REF, 0, 0, 1, 12-COUNTBLANK(this_year)))
Then you just divide it by the results this year so far:
=result_So_far_this_year / SUM(OFFSET(JANUARY_CELL_REF, 0, 0, 1, 12-COUNTBLANK(this_year)))
Finally format is as a percent.

Related

Excel Date Formula + 3 Months

I am looking to have a formula that takes the date that is manually input in a cell (E2) and automatically populates a date in the column next to it (F2) that is + 3 months from the date manually input in (E2).
eg. If (E2) has 03/11/2021 input manually then the formula in (F2) would populate 03/02/2021. image of part of the sheet
Is this what you are looking for?
=DATE(YEAR(A1),MONTH(A1)+X,DAY(A1))
where X = 3
One can use EDATE():
=EDATE(A1,3)
The second criteria is the number of Months to add.
EDATE will go to the number of months then try to equate the day. If the day exceeds the number of days in the target month it returns the last day of the target month.
For example =EDATE(DATE(2021,11,30),3) will return the 28th of February 2021.

In Excel how to count between date1 and date2 that have cells in row that contain text?

I need to choose cells in one column that are between two dates, and then based on the rows that contain those dates, choose cells in another row that also contains content.
I didn't use ISBLANK because it counts a formula yet an empty cell as a not-blank. Instead check if there is content by "*".
Here is what I came up with, but instead of returning the number of cells, instead this returns TRUE (which obviously isn't what I want).
In the formula below I am assuming:
C:C is the whole column containing DATES.
E:E is the whole column containing CONTENT.
The date range in this case is January 1, 2018 to January 31, 2018.
"*" means is there is content in the cell
=IF(AND(COUNTIFS(C:C,">="&"2018-1-1",C:C,"<="&"2018-1-31"),COUNTIF(E:E,"*"))=0,"",AND(COUNTIFS(C:C,">="&"2018-1-1",C:C,"<="&"2018-1-31"),COUNTIF(E:E,"*")))
My goal is to:
count the numbers of the cells in column E that are between the dates in column C
if the whole formula is 0, then return a blank.
See this picture of a sample excel sheet to make my intent clear:
How can I get my formula working so it does as needed?
SOLUTION
Hi all, so thanks to #girlvsdata, we have a working solution. I had to do a couple edits to her code to work for my uses, but her formula overall works perfect. Here is the solution:
To choose all cells in column E that are not blank, in between the date range of all of January (unknown end date) based on the adjacent C column if that is your date column, then the solution is:
=IF(COUNTIFS(C:C,">="&"2018-1-1",C:C,"<="&EOMONTH("2018-1-1",0),E:E,"*")=0,"",COUNTIFS(C:C,">="&"2018-1-1",C:C,"<="&EOMONTH("2018-1-1",0),E:E,"*"))
Note that "2018-1-1" is January 1 2018, and EOMONTH("2018-1-1",0) is the last valid day of January in the year 2018 (in this case, 31, but if it is different another year (e.g. for February this works for leap years too) then it will be that last day). Also it eliminates the need to calculate which is the last day or every month, as well as months that have changing end dates dependent on the year (e.g. Feb). This is important to eliminate a margin of error.
The only thing you have to do to change the month is only change e.g. -1- (Jan) to -2- for Feb, or change the year for other years. With this formula you can ignore the day part.
If the answer is 0 (no cells have any content in between the range), then the cell is blank instead of 0. (GOod for when you want to create a sheet checking future dates for future reference when more rows are added to the sheet.
It also works across different sheets, just use, say your other sheet is called "Tracker" then use Tracker!C:C and Tracker!E:E. Hope it helps!
Thank you all! :D
(Please note: My local date format is day, then month)
With the data laid out as in your example above:
A B
1 Dates |Content
------------+-------
2 1/01/2018 |
3 2/01/2018 |123456
4 3/01/2018 |
5 4/01/2018 |12398
6 5/01/2018 |484
7 6/01/2018 |1538
8 7/01/2018 |
9 8/01/2018 |
10 9/01/2018 |
11 10/01/2018 |14648
12 11/01/2018 |
13 12/01/2018 |145615
14 13/01/2018 |
And with the date range in cells D2 and E2:
Date Start Date End
2/01/2018 7/01/2018
This formula returns the count:
=COUNTIFS(A:A,">="&D2,A:A,"<="&E2,B:B,">0")
This will depend on whether your numbers in Column B are formatted as text or number. If they are formatted as numbers, the above formula will work. If they are formatted as text, replace the last section ">0" with "*".
This formula adds the conditional part of your question:
=IF(COUNTIFS(A:A,">="&D2,A:A,"<="&E2,B:B,">0")=0,"",COUNTIFS(A:A,">="&D2,A:A,"<="&E2,B:B,">0"))
(If the formula returns 0, show blank)

Conditional Sum (based on current week)

I have an excel 2010 Workbook. Within this there are two columns.
The first column represents numerical week 1 (1-52 rows), the second contains a numeric value (never blank)
I would like a formula which basically sums all the rows (2nd column) up until the current week. So today it would sum the rows 1 through 11, next week it would sum 1 through 12
Tried a SUMIF but could not get it working (always zero)
Try this:
=SUMIF(A1:A52,"<="&WEEKNUM(TODAY(),2),B1:B52)
Where your week numbers run from A1:A52 and your values run from B1:B52.
You can also define which day the week begins on within the WEEKNUM() function by changing the second parameter. It is currently set to 2 which is based on the week beginning on Monday.

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: Extract full months between date ranges

Users are entering date ranges into an Excel spreadsheet. These date ranges span multiple months. What I'd like is for a field to display how many full months are represented in the date range.
For example:
User enters 8/25/2014 and 12/19/2014
Calculated field = 3
The full months represent September, October, and November. August and December are only partial months.
Assuming start date in A2 and end date in B2 use this formula for the number of full months
=DATEDIF(EOMONTH(A2-1,0)+1,B2+1,"m")
That will give you 3 for your example - if you change the start date to 8/1/2014 (or the end date to 12/31/2014) you will get 4 (or if you do both you'll get 5)

Resources