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 8, 2018 in Tableau by ghost
• 1,790 points
1,012 views

1 answer to this question.

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 8, 2018 by Nitish
• 630 points

Related Questions In Tableau

0 votes
1 answer

Tableau: How to create a filter based of 3 different columns?

The case you're using for filters is ...READ MORE

answered Mar 16, 2022 in Tableau by Vaani
• 7,070 points
2,806 views
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,240 points
9,891 views
0 votes
1 answer

How to create a global filter

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

answered Apr 13, 2018 in Tableau by QueenBee
• 1,820 points
1,472 views
0 votes
1 answer

How to hide measures on a Tableau filter?

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

answered Jul 11, 2018 in Tableau by ffdfd
• 5,550 points
2,399 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 15, 2018 in Tableau by AwesomeSauce
• 860 points
1,653 views
0 votes
1 answer

Date filter - Tableau

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

answered May 8, 2019 in Tableau by Cherukuri
• 33,030 points
732 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 10, 2018 in Tableau by Atul
• 10,240 points
1,502 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
• 860 points
2,447 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
3,003 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
1,609 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP