Excel formula to increase month by one and week in month by one - excel

I need a formula to increase the week in month by one as well as increase the month by one.
Basically I need an ongoing list of Mondays that would follow this pattern:
Month 1 2016, Week 1 2016, Monday = 4th Jan 2016
Month 2 2016, Week 2 2016, Monday = 8th Feb 2016
Month 3 2016, Week 3 2016, Monday = 21st Mar 2016
Month 4 2016, Week 4 2016, Monday = 25th Apr 2016
Month 5 2016, Week 1 2016, Monday = 2nd May 2016
Month 6 2016, Week 2 2016, Monday = 13th Jun 2016

as below
month date_of_first_Monday how_many_Mondays Ith_Monday_request the_date_request
1/1 =Choose(Weekday(A2,2),0,6,5,4,3,2,1)+A2 =roundup((day(eomonth(a2,0))-weekday(eomonth(a2,0),3))/7,0) =if(month(a2)=1,1,if(d1+1>c2,1,d1+1)) =b2+7*(d2-1)
2/1
3/1

Related

Excel function to dynamically SUM UP data based on matching rows and columns

I have a table with metrics shown as rows and month shown as columns.
Example is below:
Quarter
2022-01-01
2022-01-01
2022-01-01
2022-04-01
2022-04-01
2022-04-01
2022-07-01
2022-07-01
2022-07-01
2022-10-01
2022-10-01
2022-10-01
Month
2022-01-01
2022-02-01
2022-03-01
2022-04-01
2022-05-01
2022-06-01
2022-07-01
2022-08-01
2022-09-01
2022-10-01
2022-11-01
2022-12-01
Metrics
Jan 2022
Feb 2022
Mar 2022
Apr 2022
May 2022
Jun 2022
Jul 2022
Aug 2022
Sep 2022
Oct 2022
Nov 2022
Dec 2022
Revenue
1000
1000
1000
500
500
500
100
100
100
0
0
0
Cost
10
10
10
10
10
10
20
20
20
0
5
10
I want to have a dynamic summary table of quarterly data. I can use sumifs and look up the quarter month using this function:
SUMIFS([Value row range],[Quarter range],[Quarter wanted])
However, i still have to manually select the correct value row range to sum. Is it possible to select the entire table and then match the correct row based on matching labels (metric in this case)?
Insert Report Month
Dec-22
Last 3 quarter report
Metrics
Q2 2022
Q3 2022
Q4 2022
Revenue
1500
300
0
Cost
30
60
15
I'm aware of the index & match function, but it only looks for the first match and does not sum up all months in the same quarter.
Thanks for helping!
Excel 365 for MAC should have the BYCOL function,
Given:
Your data table is a Table named Metrics
Report_Month is a Named Range containing a "real date" in the month of the final month of the desired quarter.
The following formula will return your output and will adjust as you add columns to the data table.
A11: =Metrics[[#All],[Metrics]]
B11: =LET(x,EDATE(Report_Month,SEQUENCE(,3,-6,3)),TEXT(MONTH(x)/3,"\Q0 ") & YEAR(x))
B12: =BYCOL(XLOOKUP(TEXT(DATE(YEAR(Report_Month),MONTH(Report_Month)-9+SEQUENCE(3,,1,1)+SEQUENCE(,3,0,3),1),"mmm-yy"),Metrics[#Headers],INDEX(Metrics,XMATCH(A12,Metrics[Metrics]),0)),LAMBDA(arr,SUM(arr)))
Select B12 and fill down as far as needed.
Notes
DATE(YEAR(Report_Month),MONTH(Report_Month)-9+SEQUENCE(3,,1,1)+SEQUENCE(,3,0,3),1)
creates a matrix of the previous nine month starting dates with each column consisting of a given quarter:
So for 12/1/2022 =>
The TEXT function then formats the same as the column headers in the Metrics table.
XLOOKUP will then return the appropriate columns from the table into that matrix, and using the BYCOL allows us to SUM by column which is the relevant quarter.

Excel: Dynamic Range Date used in other fields: Sumproduct

I am using sumproduct formula to get the first four month, then the second four month, third four month of net sales until one month before today. This is my formula that I used:
=IFERROR(SUMPRODUCT($B3:$Y3*(COLUMN($B3:$Y3)>=AGGREGATE(15,6,COLUMN($B3:$Y3)/($B3:$Y3<>0),1)+4*(COLUMNS(B3)-1))*(COLUMN($B3:$Y3)<AGGREGATE(15,6,COLUMN($B3:$Y3)/($B3:$Y3<>0),1)+4*(COLUMNS(B3)))*($B$1:$Y$1<EOMONTH(TODAY(),-1)+1)),0)
However, I need to capture the same range as I have it for the net sales as for other measures like COGS in my example. I cannot use the formula above for the other measures like COGS as sometimes they are zero in the same range as in the Net Sales.But I need to capture the zeros here as well.
Example 1
Example 2
Net Sales
Jan
Feb
Mar
Apr
May
June
July
Aug
Sept
Oct
Nov
Dec
0
0
2
3
4
5
2
3
2
3
2
4
---> 1st period= 14 2nd period= 10
COGS (follows the same date range as Net Sales)
Jan
Feb
Mar
Apr
May
June
July
Aug
Sept
Oct
Nov
Dec
0
0
0
0
0
2
1
4
2
3
2
4
---> 1st period= 2 2nd Period= 11
You can leave the entire range check logic from the first formula and change just the value range, i.e first formula in my sample:
=IFERROR(SUMPRODUCT($A3:$L3*(COLUMN($A3:$L3)>=AGGREGATE(15,6,COLUMN($A3:$L3)/($A3:$L3<>0),1)+4*(COLUMN(A3)-1))*(COLUMN($A3:$L3)<AGGREGATE(15,6,COLUMN($A3:$L3)/($A3:$L3<>0),1)+4*(COLUMN(A3)))*($A$2:$L$2<EOMONTH(TODAY(),-1)+1)),0)
second formula for COGS:
=IFERROR(SUMPRODUCT($O3:$Z3*(COLUMN($A3:$L3)>=AGGREGATE(15,6,COLUMN($A3:$L3)/($A3:$L3<>0),1)+4*(COLUMN(A3)-1))*(COLUMN($A3:$L3)<AGGREGATE(15,6,COLUMN($A3:$L3)/($A3:$L3<>0),1)+4*(COLUMN(A3)))*($A$2:$L$2<EOMONTH(TODAY(),-1)+1)),0)

Counting the weekday number in excel

Is it possible to count the weekday number in excel?
Let's say
A
B
Aug 1
Aug 2
1
Aug 3
2
Aug 20
15
Aug 30
22
Sep 1
1
Sep 2
2
Sep 3
3
Sep 4
Sep 5
Sep 6
4
Aug 1 is a Sunday so it is blank, Aug 2 is a Monday and it's the first weekday of the month so it counts as number 1, Aug 3 as number 2, Aug 20 as number 15 all the way to Aug 31 which is number 22. Then it starts counting again the following month.
Can this be done without VBA?
Use NETWORKDAYS to return the workdays and wrap in IF to get blank the weekends:
=IF(WORKDAY(A1-1,1)=A1,NETWORKDAYS(EOMONTH(A1,-1)+1,A1),"")
You can also provide a range in the option third criterion of NETWORKDAYS and WORKDAY to include a list of holidays to not count.

Look up a date value from each cell in a column and return a year date dependent upon where date falls between two dates

I'm wanting to add formula to locate the Policy Year in each cell in column B (starting in B2) which is determined from interrogating the date shown in the corresponding cell in Column A and then checking whether it sits in a range (inception date and expiry date) D2:E5 The Policy Year sits in C2:C5 I've shown the values I'd expect the formula in the cells in column B to draw from Column C.
COLUMN A COLUMN B EXPECTED VALUE COLUMN C COLUMN D COLUMN E
2 April 2017 2016 2016 5 December 2016 4 December 2017
5 June 2017 2016 2017 5 December 2017 4 December 2018
6 December 2017 2017 2018 5 December 2018 4 December 2019
4 January 2018 2017 2019 5 December 2019 4 December 2020
6 August 2018 2017
4 December 2018 2017
29 December 2018 2018
6 March 2020 2019

How to display all birthday days till 2025 starting from originating year

from datetime import date,time,timedelta
d = int(input("Enter the year:"))
while (d < 2025):
d += 1
dt = date(month = 4, day = 6, year = d)
print(d,":",dt.strftime("%A"))
I have coded to get all my birthday days till 2025.But how to start with originating year
output:
Enter the year: 1997
1998 : Monday
1999 : Tuesday
2000 : Thursday
2001 : Friday
2002 : Saturday
2003 : Sunday
2004 : Tuesday
2005 : Wednesday
2006 : Thursday
2007 : Friday
2008 : Sunday
2009 : Monday
2010 : Tuesday
2011 : Wednesday
2012 : Friday
2013 : Saturday
2014 : Sunday
2015 : Monday
2016 : Wednesday
2017 : Thursday
2018 : Friday
2019 : Saturday
2020 : Monday
2021 : Tuesday
2022 : Wednesday
2023 : Thursday
2024 : Saturday
2025 : Sunday
Can you try by increasing the count after you're printing the date ?
from datetime import date,time,timedelta
d = int(input("Enter the year:"))
while (d < 2025):
dt = date(month = 4, day = 6, year = d)
print(d,":",dt.strftime("%A")) # print current year
d += 1 # then increment to +1

Resources