Month/Year dropdown filter

Hi

I’m trying to use a date filter for a date field to display similar to the below that can be done in Tableau. Currently i can only see the option for a relative date or a manual date range picking start and end dates but i would like it to be like the below ?

Hi @steven.fisher

Welcome to the Quick Suite community!

Use the extract function to derive the year and month number from your date field, then use an ifelse based on the month number to generate the month name. Finally, concatenate the month name and year to create a Month/Year field that you can use as a filter.

Year -  extract('YYYY', {Date Field})

MonthNo  -  extract('MM', {Date Field})

MonthName -
ifelse(
    {MonthNo}  = 1, 'Jan',
    {MonthNo}  = 2, 'Feb',
    {MonthNo}  = 3, 'March',
    {MonthNo}  = 4, 'April',
    {MonthNo}  = 5, 'May',
    {MonthNo}  = 6, 'June',
    {MonthNo}  = 7, 'July',
    {MonthNo}  = 8, 'Aug',
    {MonthNo}  = 9, 'Sept',
    {MonthNo}  = 10, 'Oct',
    {MonthNo}  = 11, 'Nov',
    {MonthNo}  = 12, 'Dec',
    NULL
)

Month/Year - concat(MonthName , ' ', Year )

Thank you for the reply but i am getting a message saying error found with a red line under the M of the MonthNo, with no further details

Hi @steven.fisher

Could please share the error message and make sure to replace the date field from your dataset.

HI @Xclipse

this is the error when i hover over the red line

image

Hi @steven.fisher

Please remove Year - and use only extract('YYYY', {Date Field}).

The following are the calculated field names

  • Year
  • MonthNo
  • MonthName
  • Month/Year

Thanks @Xclipse

It’s getting closer but now the error has moved to the last line

image

Hi @steven.fisher

Please remove MonthNo - and use only extract('MM', {Date Field}) and for “MonthName” calculation remove MonthName - and use only
ifelse( {MonthNo} = 1, 'Jan', {MonthNo} = 2, 'Feb', {MonthNo} = 3, 'March', {MonthNo} = 4, 'April', {MonthNo} = 5, 'May', {MonthNo} = 6, 'June', {MonthNo} = 7, 'July', {MonthNo} = 8, 'Aug', {MonthNo} = 9, 'Sept', {MonthNo} = 10, 'Oct', {MonthNo} = 11, 'Nov', {MonthNo} = 12, 'Dec', NULL ) and for “Month/Year” calculation remove Month/Year - and use only concat(MonthName , ' ', Year )

HI @Xclipse

the error has moved again

image

extract(‘YYYY’, {Reporting Month})

extract(‘MM’, {Reporting Month})

ifelse(

{MonthNo}  = 1, 'Jan',

{MonthNo}  = 2, 'Feb',

{MonthNo}  = 3, 'March',

{MonthNo}  = 4, 'April',

{MonthNo}  = 5, 'May',

{MonthNo}  = 6, 'June',

{MonthNo}  = 7, 'July',

{MonthNo}  = 8, 'Aug',

{MonthNo}  = 9, 'Sept',

{MonthNo}  = 10, 'Oct',

{MonthNo}  = 11, 'Nov',

{MonthNo}  = 12, 'Dec',

NULL

)

concat(MonthName , ’ ', Year )

Hi @steven.fisher

You should create 4 different calculated fields

Example:
Note: Replace the date field from your dataset

  • Year - Extract the year from the Date field
extract('YYYY', {Date Field})
  • MonthNo - Extract the month number from the Date field
extract('MM', {Date Field})
  • MonthName - Get the month name based on the MonthNo calculated field
ifelse(
    {MonthNo}  = 1, 'Jan',
    {MonthNo}  = 2, 'Feb',
    {MonthNo}  = 3, 'March',
    {MonthNo}  = 4, 'April',
    {MonthNo}  = 5, 'May',
    {MonthNo}  = 6, 'June',
    {MonthNo}  = 7, 'July',
    {MonthNo}  = 8, 'Aug',
    {MonthNo}  = 9, 'Sept',
    {MonthNo}  = 10, 'Oct',
    {MonthNo}  = 11, 'Nov',
    {MonthNo}  = 12, 'Dec',
    NULL
)
  • Month/Year - Concatenate the MonthName and Year calculated fields
concat(MonthName , ' ', toString(Year))

Year

MonthNo

MonthName

Month/Year

Thanks that works but if i use it as a filter its in alphabetical order as this is a string do you know anyway i can get the months in the correct order of month/year rather than April 2023, April 2024, April 2025, Aug 2023 etc

Hi @steven.fisher

By default, the filter sorts the values alphabetically. If you want to sort the months in chronological order, you need to append the month number to the month name (for example, “01-Jan”) so that the sorting works numerically.

Thanks @Xclipse combining your suggestions with some trial and error i’ve resolved it