4 Replies Latest reply on Apr 29, 2018 3:29 PM by Okechukwu Ossai

# Calculation for comparing status between 2 dates

Hi,

I am looking for some help for creating a calculated field to get counts of id in each status that did not change between two dates giving users an option to choose the dates.  Please find the sample data attached.

• ###### 1. Re: Calculation for comparing status between 2 dates

Hi, Salla

Is it something like this?

ZZ

• ###### 2. Re: Calculation for comparing status between 2 dates

Hello Zhouyi Zhang,

No, I only want to see the distinct count of  Id's  who's status did not change between 2nd and 5th. example Id's 1, 3, 5 remained in Active status. so the count of Id's who remained in active status is 3

• ###### 3. Re: Calculation for comparing status between 2 dates

Hi, Salla

In this case, you need create another filter as shown below to filter the ids.

An updated workbook attached for your reference.

ZZ

• ###### 4. Re: Calculation for comparing status between 2 dates

Hi Salla,

You will need to use parameters if you want to give users the option to choose the date range for comparison. Bear in mind that parameters are currently not dynamic in Tableau. So you may need to manually update the the end date parameter when necessary.

Step 1: Create parameter [Start Date]

I used Range in allowable values with a distant maximum date value. You can use whatever is best for you here.

Step 2: Create parameter [End Date]

Same comment as above.

Step 3: Create calculated field [Status Unchanged?]

IF {FIXED [Id]:  COUNTD(IF [Date] >= [Start Date] AND [Date] <= [End Date] THEN [Status] END)} = 1 THEN 'Yes' ELSE 'No' END

Step 4: Create calculated field [# of Id with Unchanged Status]

COUNTD(IF [Status Unchanged?] = 'Yes' THEN [Id] END)

See attached workbook in version 10.1.

Hope this helps.

Ossai

1 of 1 people found this helpful