Excel formula to calculate YTD metrics by detecting current month - excel

I have two excel tables - 2015 sales and 2014 sales in the following format. And a third table called Year over Year Variance which looks at % change in 2015 over 2014.
2015 Jan Feb Mar .... YTD (total)
Orders
Revenue
...
...
2014 Jan Feb Mar .... YTD (total)
Orders
Revenue
...
...
Variance Jan Feb Mar .... YTD
Orders
Revenue
...
...
Computing Jan variance over Jan or Feb variance over Feb is simple. How do I compute Year to date variance. Because the 2014 table is already populated for the whole year - so the last column is the sum of 12 months of data.
For 2015, I only have Jan and Feb. So the variance column for Year to date should be (Jan+Feb 2015)/(Jan+Feb 2014). How do I write a formula to check for the current month and then sum only those two months for the year to date calculation?

Using Excel formulas (no-VBA), you can couple the SUM, OFFSET, and COUNT functions to calculate the variance. In the simplified formula below, Row 1 is fully populated across all 12 months. Row 2 is only populated for 2 months. Using the COUNT formula across the range, the OFFSET will expand the width based on the number of populated rows.
Let me know if you have any problems adapting it.
=SUM(OFFSET($A$2,0,0,1,COUNT($A$2:$L$2)))/SUM(OFFSET($A$1,0,0,1,COUNT($A$2:$L$2)))

=Month(Today())
will return the current month (integer, 1-12) in the spreadsheet.
Month(Now)
will do the same thing in VBA code.
I'd use a formula in the 3rd table along the lines of
=if(Month(Today())<=Month(*date-of-column-header*), *Computed-Variance*, 0)
That way, you simply have zero show up in the cells where the comparison makes no sense, and your sum of the numbers in the row is unaffected.

Related

How to get week number based on Two dates based Conditions in Excel

I have a DateTime column in Excel in which data is sorted in ascending order based on DateTime conditions from 15th June to say 1st November ;
I want to print Week Number from 1st to Nth Week based on date condition; Week criteria are like first seven days i.e 15th June to 21st June is Week1, 22nd Jun-28th Jun is Week2, 29th June - 5th June is Week3 and so on.
How Can I do this?
Column1
06/15/2021 8:00
06/15/2021 10:00
:
:
11/01/2021 20:44
11/01/2021 20:46
Let's assume your list of dates is in A2:A.
Place the following formula in cell B2 of an otherwise empty range B2:B...
=ArrayFormula(IF(A2:A="",,ROUNDDOWN((INT(A2:A)-INT(A2))/7)+1))
INT is just removing the times from date-times.
The rest is really more of a math/logic question than a formula question.

With having two dates now i month wise days calculation required

I have two dates. Now my aim is to calculate the number of days, month wise for n number of rows
Input:
start date 22/01/2019
finish date 21/06/2019
Output & result should be
January February March April May June
9 28 31 30 31 21
for many rows.
Excel or VBA Excel formula both will be great,
Thanks in advance....
Here is a screenshot of my Excel table:
https://ibb.co/tC38jzs
Here is a simple solution if your Active Month column entries are not the names of the month, but the last day.
31.01.2019 28.02.2019 ...
For the January column you can then use
=MAX(0, MIN($AV14-$AT14, AY$13-$AV14))
and for the other months you have to subtract the days aggregated since January. Here for February:
=MAX(0, MIN($AV14-$AT14, AZ$13-$AV14) - SUM($AY14:AY14))
Expand the last formula from Feb to Dec.

Calculating Based on an Array in Excel

I have a Pivot Table that I am able to cycle through the different months based on a Month Filter (changing the data of the table). I am trying to calculate based off of that change of value. I am recording the amount of times a license is used in a workday. The number of workdays in a month change based on the month. I calculated out the workdays for each month using
=NETWORKDAYS(H34,EOMONTH(H34,0),J34:J45)
H34 references my 1/1/2016 date. J34:J45 references my holiday dates to avoid.
I am trying to write a formula that says "If the month listed (from my month filter) within the Months list then to print the corresponding Workdays value.
=IF(G34:G46=H48, I34:I46)
It only works on January. The rest of the values return False. I do calculate it as an Array Function. It returns either False. I cannot think of another function that could replace it. Any help would be appreciated.
2016
Month Date Workdays Holiday Dates Holidays
January 1/1/2016 19 1/1/2016 New Year's day
February 2/1/2016 20 18-Jan Holiday 2
March 3/1/2016 22 2/15/2016 Valentines day
April 4/1/2016 21 3/25/2016 St. Patrick's Day
May 5/1/2016 21 5/30/2016 Memorial Day
June 6/1/2016 22 7/4/2016 Independence Day
July 7/1/2016 21 9/5/2016 Labor Day
August 8/1/2016 23 10/10/2016 Holiday
September 9/1/2016 22 11/8/2016 Columbus Day
October 10/1/2016 21 11/11/2016 Veteran's Day
November 11/1/2016 21 11/24/2016 Thanksgiving
December 12/1/2016 21 12/26/2016 Christmas
All 235
Selected Month
March FALSE
The VLOOKUP() function will greatly simplify this process for you. This particular function is great for extracting values in a list based on a key lookup field.
In your example, you want to easily extract the value from Holiday Dates column based on an input month.
A few things to keep in mind for the input parameter functions in this function:
The first column in your table array must contain the lookup value, in this case, the month column.
If may need to lock your array dimensions, use the $ sign in front of the column letter and row number.
FALSE should be selected for the range_lookup in order to do exact matching for the lookup value. If you choose false, you may get false positivies.
Every row in your list should be unique for the lookup value. Let's say January was listed twice, the value returned would be for the first occurrence.
Additional info:
http://spreadsheeto.com/vlookup/
http://www.howtogeek.com/howto/13780/using-vlookup-in-excel/
You can use the LOOKUP function, as follow:
=VLOOKUP(G48,G34:I45,3)
This formula looks up "G48" value in column G (first matrix column), and returns the value from column I (third matrix column) that is in the same row.
Read this official Office page for more details.
Please, give us your feedback.

How to find the last 8 quarters and their years from the current quarter and year or a given date

I am trying to find the last 7 quarters from the given quarter and year in MS Excel.
For eg.
if I have Q1 2016 then I should be able to find Q4 2015 in one cell and Q3 2015 in another cell and so on showing the last seven quarters. This should be dynamic i.e when the current quarter changes, the year should move also wherever required.
I have been able to find the last quarter number using the following formulas:
=CHOOSE(CEILING(MONTH(E4)/3,1),1,2,3,4)
and
=IF(F5-1=0,4,F5-1)
But I am not able keep the year dynamic.
If the current quarter is Q1 2015 then the quarters I need would be:
Q4 2015
Q3 2015
Q2 2015
Q1 2015
Q4 2014
Q3 2014
Q2 2014
Your question is not clear. But, with some date in E4, the following formula will return Qn YYYY. If you then fill right, it will return the preceding quarters. If your layout is different, you will need to adjust the formula accordingly.
EDIT Formula adjusted to be able fill right instead of down
F5: ="Q" & INT(MONTH(EDATE($E$4,-(COLUMNS($A:A)-1)*3))/3)+1 &" " & YEAR(EDATE($E$4,-(COLUMNS($A:A)-1)*3))
The formula subtracts a multiple of 3 months from the date in E4; and computes the quarter and year for that date. By using the ROWS function, that multiple is incremented each time you fill down one row.

add values for a range between reference date minus 6 days in excel

i would like to add the corresponding values of dates with reference to a particular date and -6 days in excel.
For example: reference date is 10th feb 15. I would like to add values under flight time column for dates ranging between 10th feb 15 and previous 6 days.
similarly add values for a reference date and previous 30 days values and 1 year values.
What i wanted was, sum all the flight timings of a particular date in column A. I used the sumifs formula to achieve this.
The formula is =SUMIFS($I$8:$I$1122,$A$8:$A$1122,"<="&C8,$A$8:$A$1122,">="&C8-6)
What it does: Here the reference cell is C8 which is 6th Feb 14
step 1- date range for the calculation is 6th feb 14 minus 6 days
step 2- add the values of column I which correspond to all the dates that fall within 6th feb 14 to 31st jan 14
step 3- indicate the sum in column K
Unfortunately i cannot include any pictures or files to show what i have mentioned due to site limitations.

Resources