• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

I want only 4-5 weeknum in a month

aparvez007

Member
Dear All,


I have date from 1-jan-2013 to 31-Dec-2013.

I want only week no. 1 to 5 then again in feb from 1 to 4 in march 1 to 4 so on....

I dont want all 52 week. every month 4 or 5 week


Thanks

Pavi
 
If 1st week begins with 1st day of month and week beginning definition is Saturday then the first week will have irregular count of days.

[pre]
Code:
e.g.
1st Feb ---> 1st Week ---> Friday
2nd Feb ---> 2nd Week ---> Saturday
[/pre]

Is above thinking correct or is it different?
 
Formula is little ugly but I think it should work:


=SUMPRODUCT(--(WEEKDAY(EOMONTH(A1,-1)+ROW($A$1:INDEX(A:A,A1-EOMONTH(A1,-1))))=7))+1
 
Dear it's working like charm...

can you please explain the formula like what is the logic behind this (--( 'looking like sad face but giving correct answer.

If I want to change the first week of the day then wat should i need to change.


Regards,

Pavi
 
Hi,


* Basically, the formula counts number of Saturdays starting from Day 1 of the month to the specified date.


* Weekday function returns 7 for Saturday so we use it for checking if a day is Saturday. So if your week beginning is Sunday then it will be =1 in place of =7.


* EOMONTH(A1,-1) returns last date of previous month which we use as starting point.


* ROW($A$1:INDEX(A:A,A1-EOMONTH(A1,-1))) returns an array of number of days upto out given date in cell A1 like {1,2,3,4,5,6,7}


* These are added to give all dates starting from Day 1 of the month to date specified in the month, inclusive of both.


* Then WEEKDAY function simply count number of Saturdays and adds 1 to the final total [This is flawed logic, see below I have corrected it]. This conditional calculation is done by SUMPRODUCT. '--' means double unary which converts boolean (TRUE / FALSE) result to number (1 / 0).


So I think this formula will fail if the first day of month is a Saturday. So it needs small adjustment to logic.


=SUMPRODUCT(--(WEEKDAY(EOMONTH(A1,-1)+ROW($A$1:INDEX(A:A,A1-EOMONTH(A1,-1))))=7))+(WEEKDAY(EOMONTH(A1,-1)+1)<>7)*1


I have replaced 1 with condition check for the first day of month being Saturday.
 
Hi ,


If you don't mind a different approach , try this ; if you want the formulae in column B , starting with B1 , then in B1 put the number 1 , since the first day will always be in week 1. Starting with B2 , use the following formula , and copy it down :


=IF(MONTH(A2)<>MONTH(A1),1,IF(WEEKDAY(A2)<>7,B1,B1+1))


Narayan
 
Narayan,


Excellent point. I think requirement for this solution would be days listed serially.


Here's one more generic solution which will evaluate the week number.

=INT((A1-(EOMONTH(A1,-1)+1+(7-WEEKDAY(EOMONTH(A1,-1)+1)))+7)/7)+(WEEKDAY(EOMONTH(A1,-1)+1)<>7)*1
 
Shrivallabha you explain very well thanks alot...


but your formula remind me my school days when any new chapter started in the class i look same like now i am looking your formula which bouncing from my head... u r great shri...


Thanks Narayan for your short formula.


Shri your last formula also working fine.


Regards,

Pavi
 
Hi All,


I use below formula please tell me if have easy or other formula for this?


=IF(DAY(D2)<=7,"1st Week",IF(DAY(D2)<=14,"2nd Week",IF(DAY(D2)<=21,"3rd Week",IF(DAY(D2)<=28,"4th Week","5th Week"))))


Regards,

Pavi
 
Try:

=LOOKUP(DAY(D2),{1,8,15,22,29},{"1st","2nd","3rd","4th","5th"})&" Week"


and


=CHOOSE(INT((DAY(D2)-1)/7)+1,"1st","2nd","3rd","4th","5th")&" Week"
 
Back
Top