7 Replies Latest reply on Feb 4, 2019 12:30 AM by Dony R Djafar

# Count of No. of Days through the month

Hi Tableau Lovers,

I counted the number of days using this formula:

No. of Current Days     : "Day (Today ()-1)"

No. of Days                  : "DATEDIFF ('day', DATETRUNC ('month', [Transaction Date]), DATETRUNC ('month', dateadd ('month', 1, [Transaction Date])))"

I experienced difficulties when I wanted to filter into the previous month to form a "no of current days = no of days".

when i filter to the previous month, No. of Current Days is 2.

Is there a correct way to formulate it when I want to filter to the "previous month" like below?

Thank You,

Best Regards,

Dony

• ###### 1. Re: Count of No. of Days through the month

good morning

you could put in a check on the No current days - something like -

if datetrunc('month',today())<>datetrunc('month',[transaction date])  then "Day (Today ()-1)" else

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

• ###### 2. Re: Count of No. of Days through the month

Hi Dony,

In addition to directions provided by Jim Dehner  find my approach as reference below and stored in attached workbook version 10.5 located in the original thread.

1. D1. Date (Months)

2. M1. No. of Days: countd([Date])

3. M2. No. of Current Days: {fixed [D1. Date (Months)]:sum(if [Date]<=(today()-1) then 1 end)}

Hope it helps,

Regards,

Norbert

• ###### 3. Re: Count of No. of Days through the month

Good morning Norbert - hope all is well -

Jim

• ###### 4. Re: Count of No. of Days through the month

Hi Jim,

Thanks for the formula, but if I use that and filter february.

Jan

no of current day : 31

no of days : 31

Feb

no of current day : 28

no of days : 28

where now is 4 feb 2019 or 4 Days for "no of current day".

Hi Nobbert,

Thanks for the example, but if I using it, my actual to be below:

no of current day to be very much day.

How can I find the right formula?

if i want the result like below :

Jan

no of current day : 31

no of days : 31

Feb

no of current day : 3

no of days : 28

Total

no of current day : 34

no of days : 59

Thank you,

Best Regards,

Dony

Sorry if my english is very bad.

• ###### 5. Re: Count of No. of Days through the month

Hi Jim,

Thanks for the message. Finding my way back after the NO-adventure.

Regards,

Norbert

• ###### 6. Re: Count of No. of Days through the month

Hi Dony,

Find my updated approach

Hope it helps,

Regards,

Norbert

• ###### 7. Re: Count of No. of Days through the month

Hi Norbert,

In your example, in 1 day(date) just 1 transaction. so you can "COUNTD" it correctly.

But in my case, in 1 day(date) have a much transaction, so if i "COUND" transaction date will have no of days.

Could you know, how to "COUND" it correctly?