filmov
tv
How to calculate the Total Number of Days in Each Month in Tableau
Показать описание
In this view I have month of date and I have two metrics count of days that exist in the data set and the total number of days in each month. So in December 2021 there were 30 days of sales and also 30 days in December.
I have a new sheet open and I've put month of date into the view. The first question is how many months of sales were there. Add a calculated field this one's simple it's just called count of dates. It's simply going to be count d of date count distinct of date how many dates exist in this data.
Let's move that up to columns so in January 2018 there were 21 days that they had sales in this data.
The second the second calculation is a little bit more complex amount of possible days in each month. January has 31 February 28 and so on. I have a field called count of possible days. I'm going to edit that and explain what it's doing. I have an if statement I'm testing if the month is in a month that has 30 days then output 30. If the month is in a month that has 31 days then output 31.
February is more complex so if it month is 2 so it's February and year is in a leap year then output 29. If month is equal to 2 and not a leap year then it's going to be 28.
I'm going to take the max of that entire if statement drag That Into The View.