How to create a drop down for different type of date fileds

Good day,

Basically I have add the filter option to the dashboard for two different date fields which are Batch date and Selection date as shown in below.

image

Could some one help me how to create the one drop down for both the date fields. These should be listed as a “Date Type” for the filter name and then users should be able to pick one of these two options.

Thank you!

hi @tdr_Dinesh, can you go through this link so that you have some idea to build your solutions.

Thanks & Regards
Biswajit Dash

1 Like

If you want to just filter by one of the two date fields and not both, you can also take a look at this post:

This solution isn’t specific to date fields. You have one control to select what field would want to filter by and the second control is your actual filter.

1 Like

Hi @David_Wong , Thank you for your prompt response.

Yes, I want to just filter by one of the two date fields and not both.

  1. I have added the parameter as a “TEST”
  2. Added the parameter as a control with the following values: Batchdate and Selection Date
  3. Created a calculated field using the parameter
    ifelse(${TEST}=“Filter by BatchDate”,BatchDate,${TEST}=“Filter by SelectionDate”,SelectionDate,null)

image

But unfortunately I am not getting the accurate results and for both the dates I am getting the same results.

Could you please guide me further. Thank you!

Are your 2 date fields called BatchDate and SelectionDate?

The value of the parameter in your calculated field has to match the values in your first control. If the first control contains BatchDate and SelectionDate, your calculated field should say:
ifelse(${TEST}=“BatchDate”,BatchDate,${TEST}=“SelectionDate”,SelectionDate,null)

Then you need a second control to apply a filter on that calculated field.

The first control is to allow you to set the value of the parameter and choose between BatchDate and SelectionDate. The second control is to allow you to select the date.

1 Like

Hi @David_Wong ,

Thank you!

yes, date fields called Batchdate and Selectiondate.

I hope somewhere I missed out , I am not getting the accurate results.

Below are the steps which I have followed , could you please let me know if I missed out anything here

Step 1:
Given the name as Filter1 and Static default value as ‘Batch Date’


Step 2: Added calculated Field.

Step3: Added control to Parameter

I’m not seeing the part where you added a filter on your calculated field. Maybe that’s the step you’re missing.

  1. Here’s my sample data containing 2 date fields - Order Date and Ship Date.
    image

  2. First create a parameter. Use the name of one of your date fields as default value.

  3. Next use the parameter to add a control.

  4. Then create a calculated field like this:
    image

  5. Add a filter on the calculated field and pin it to the top:

  6. You can use the value of your parameter as the name of the 2nd control.
    image

image

  1. If you select Order Date in the first control, the visual gets filtered by the Order Date field.

image

If you select Ship Date in the first control, the visual gets filtered by the Ship Date field instead.

image

2 Likes

Thank you @David_Wong .It is working as expected.

2 Likes

Thank you @Biswajit_1993 for sharing the link.

1 Like

Hi @David_Wong,

By considering one more field, the field name as “Audit complete date”. If I want this field in drop down along with the existing 2 fields. Is it works? if I use the same concept. Could you please confirm. Thank you!

Hi @tdr_Dinesh,

Yes, it will work. You can add another date field.

1 Like

Hi @David_Wong

Thank you!

1 Like