
1. Re: Calculate days per month / days per year
Hari Ankem Nov 14, 2018 5:02 PM (in response to Scott Schmeling)Are you going to give the user the option to select/specify the year for which you want to know the number of days in a month/year?
If no, does you data have a year column based on which you want to know the above data?

2. Re: Calculate days per month / days per year
Ken Flerlage Nov 14, 2018 6:52 PM (in response to Scott Schmeling)You'll need to have some dates in your data set (at least one for each month) for this to work. I used the Superstore data set and created the following calculated fields:
Days in Year
// Get the first day of the year, then the last, then calculate the difference
DATEDIFF('day',
MAKEDATE(YEAR([Order Date]), 1, 1),
MAKEDATE(YEAR([Order Date]), 12, 31)
)+1
Days in Month
// Get the first day of the month, then the last, then calculate the difference
// We get the last day by: 1) Getting the first day, 2) Adding one month, 3) Subtracting 1 day.
DATEDIFF('day',
MAKEDATE(YEAR([Order Date]), MONTH([Order Date]), 1),
DATEADD('day', 1, DATEADD('month', 1, MAKEDATE(YEAR([Order Date]), MONTH([Order Date]), 1)))
)+1
See attached workbook.

Days in Year and Month.twbx 2.4 MB
