What exactly are you basing this on? March has 31 days and April has 30 days, so where do 4 weeks and 5 weeks come from? Is this something related to a fiscal calendar?
Those were random numbers of week chosen by myself just to illustrate what I would like.
But what are you trying to calculate exactly? Every month has at least 4 weeks, but less than 5 weeks. How do you want to determine the number of weeks in a month?
I tried doing this, couldn't get through it all but here is what I did. Maybe someone can finish it.
I made a calculated filed.
Drag it to Text in Mark card and Quick table calculation: Difference
Then edit the table calculation to restrict it to monthly level.
Now this removes the first month for each year because there is no previous value for tableau to subtract from. If in your case it's January then I won't worry about it since January always have 4 weeks. If not, then it will need some work my friend.
After seeing some of the other responses, I think I understand now. I'd suggest the following:
- Create a calculated field that gets the first date of the month.
- Create another calculated field that gets the first date of the next month.
- Create calculated fields that get the week number from each of the above dates.
- Do the math to calculate the weeks.
See the attached workbook.
Number of Weeks.twbx 34.8 KB
Thank you everyone for your answers, it's very kind of you.
It really helped me resolve my problem.
Have a great day !
Good Work Anisha!!!
Based on what I am seeing, your calc is greater than 52 weeks in one year....meaning, its not accurate.