Filter dashboard by date field year values only

when trying to filter based on a date field the highest level of granularity is a day.
how can I filter by years?

after adding to controls, editing the control format to YYYY doesn’t solve it

Hello @Liran1 !

This will depend on your use case, but I would recommend trying relative date filters and setting the look back window to the last N years that you want to filter for.

If you want to filter to specific, non-sequential years, I have done a worked around in the past where I use a calculated field to return just the year date part as a string, then filter on that field.

1 Like

Thank you for the suggestion. However, my dataset contains both historical (actual) and future (predicted) values spanning from 2010 to 2030. Using last N years wouldn’t work in this case since it’s relative to the current date.

I’m looking for a solution that would allow me to:

  1. Explicitly specify a date range (2017-2028)
  2. Include both historical and future dates
  3. Filter the data regardless of the current date

Would you have any alternative approaches that could accommodate this requirement?

To filter your data by years in Amazon QuickSight, you can use a parameter control instead of the built-in date filter.

Here’s how you can set it up:

Create a new parameter in your analysis:
    Go to the "Parameters" section and click "Add parameter".
    Name the parameter something like "Year" and set the data type to "Integer".
    In the "Allowed values" section, add the range of years you want to allow (e.g., 2010 to 2030).

Create a calculated field to filter the data based on the parameter:
    Go to the "Calculated fields" section and create a new calculated field.
    Use the following formula to filter the data by the selected year:

    CASE
      WHEN YEAR({date_column}) = ${Year} THEN 1
      ELSE 0
    END

    Replace {date_column} with the name of your date column.

Add the parameter control and the calculated field to your visual:
    Drag the "Year" parameter control to your visual.
    Drag the calculated field you created in the previous step to the filter section of your visual.

Now, when you interact with the “Year” parameter control, your visual will update to show the data for the selected year, regardless of the current date. This approach allows you to filter by specific years, including both historical and future data, without being limited by the current date.

Let me know if you have any further questions or need additional assistance.

1 Like

Before seeing your reply, I found an alternative solution that worked well for me. Here’s what I did:

  1. Created a calculated field containing only the year from the date.
  2. Set up two filters based on this calculated year:
    • One for the start year
    • Another for the end year

This approach simplified the filtering process.
I would still prefer if the native date filter would allow yearly filtering though…

Thanks again :slightly_smiling_face: