5 Replies Latest reply on Nov 2, 2017 10:11 PM by Sukhdeep Kaur

# Date calculation

Hi Experts,

I need your help. I have to calculate no of patients those are fall in between two dates.

Lets say the two date fields are rx_date and Tx_date. So my calculation should be  when (rx_date)>(current period) and (tx_date)<(current period) then count(patient).

Here "current period" is user selected date, which is a parameter. If I select any date from the parameter it should be the "current period" and gives me the result based on the above condition. The "rx_date" and "Tx_date" are in date format and "current period" is in string format. I cant understand how to implement this condition in tableau.

Sudhir

• ###### 1. Re: Date calculation

Hi Sudhir,

I don't understand that why do you need Current period date in string.

I have made the parameter(current period) in date to play dynamically and defined the range as you mentioned in the attachment.

Please have a look on the workbook and let me know if anything else is required.

Thanks!!

• ###### 2. Re: Date calculation

Hi Sukhdeep,

Thanks for helping me. But I cant find your workbook where you have attached.

Sudhir

• ###### 3. Re: Date calculation

Attached Workbook

• ###### 4. Re: Date calculation

But my requirement is different. I want like this

IF  (rx_date)>(date parameter) and (tx_date)<(date parameter) then count(patient) else 0 end

Here date parameter should be in 2017-jan, 2017-feb, 2017-mar.... like this.

• ###### 5. Re: Date calculation

Hi Sudhir,

I have given this condition (rx_date)>(date parameter) and (tx_date)<(date parameter) in filter and count of customers in measure shelf which is equivalent to the formula you are saying. It is just the ways are different.

However, I have created formula in the way you required.

Please have a look and if it is correct then mark the answer as correct.

Thanks!!

1 of 1 people found this helpful