How to create a filter based on date range?

0 votes

I was new in Tableau and I was stuck while applying filters on date. I have a data set that has a field called "Start Date" and a field called "End Date".

What I want?

Create a filter with the following options:

  1. Records that have a "Start Date" prior to the current date, called "Pending Records"
  2. Records that have an "End Data" after the current date, called "Expired Records"
  3. Records that have a "Start Date" equal to or greater than the current date and have an "End Date" less than the current date, called "Active Records"

I want all of these to come under one single filter with all the three choices. Is it possible?

For adding a status for "Records with an end date within 6 months" I used this code:

IF 
(
[Start Date] > TODAY()  
) then "PendingRecord"
elseif (
[End Date] < TODAY() 
) then "ExpiredRecord" 
elseif (
[Start Date] <= TODAY() AND 
([End Date] > TODAY() AND
[End Date] > DATEADD("month",6, TODAY()))
) then "ActiveRecord"
elseif (
[Start Date] <= TODAY() AND 
([End Date] > TODAY() AND
[End Date] <= DATEADD("month",6, TODAY()))
) then "EndingIn6Months"
END

Now this piece of calculated field created a filter with 4 options. But, "EndingIn6Moths" is really a subset of ActiveRecord. So, when a user selects ActiveRecords, it should also include EndingIn6Months. Is this possible? and even is it possible to auto check a filter (EndingIn6Months) when the user checks ActiveREcords option?

Aug 7, 2018 in Tableau by ghost
• 1,790 points
27 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can use this code snippet in a new calculated field to implement the above mentioned conditions:

If [Start Date] <= [Now] and [End Date] >= [Now] then "Pending Records"
    ELSE-IF ({[Start Date] <= [Now] and [End Date] >= [Now]} and {Datediff("month",Now(),End         Date) >= 6}) then "Priority"
    ELSE-IF [Start Date] > [Now] then "Active Records"
    ELSE [End Date] < [Now] then "Expired Records"
END 
answered Aug 7, 2018 by Nitish
• 630 points

Related Questions In Tableau

0 votes
1 answer

How to color code cells of a column based on the text value in Tableau

You can use the following steps to ...READ MORE

answered Mar 27, 2018 in Tableau by Atul
• 10,200 points
946 views
0 votes
1 answer

How to create a global filter

Assuming you have created a dashboard already, ...READ MORE

answered Apr 12, 2018 in Tableau by QueenBee
• 1,810 points
22 views
0 votes
1 answer

How to hide measures on a Tableau filter?

Number of Records is just a predefined ...READ MORE

answered Jul 10, 2018 in Tableau by Atul
• 5,470 points
39 views
+1 vote
1 answer

How to add filter on different sheets based on clicks?

Go to Actions… (if you're on a dashboard, you ...READ MORE

answered Aug 1, 2018 in Tableau by Atul
• 10,200 points
25 views
0 votes
1 answer

How to display days data based on date selected in the filter by the user.

You can create a parameter for dates. Select data ...READ MORE

answered Aug 14, 2018 in Tableau by AwesomeSauce
• 830 points
29 views
0 votes
1 answer

Date filter - Tableau

Hi Karthick, 1. Add the date field to ...READ MORE

answered May 8 in Tableau by CHERUKURI
• 13,940 points
8 views
0 votes
1 answer

How can I convert week into Date(mm/dd/yyyy)?

Right click on your date field, you'll ...READ MORE

answered Aug 9, 2018 in Tableau by Atul
• 10,200 points
51 views
0 votes
1 answer

Action filter (on set) is appearing in my worksheet.

Those are the action filters that we ...READ MORE

answered Aug 17, 2018 in Tableau by AwesomeSauce
• 830 points
103 views
0 votes
1 answer

How to ignore null values in your chart?

If you right click on the bar ...READ MORE

answered Aug 20, 2018 in Tableau by Nitish
• 630 points
28 views
0 votes
1 answer

How to reduce time taken to compute filters in Tableau?

You can apply the context filtering before ...READ MORE

answered Aug 20, 2018 in Tableau by Nitish
• 630 points
26 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.