amazon-quicksight

QuickSight string to month name


I have some basic strings:

month
3
4
8
11
12

I want to output month names as well as them being sortable by month (not alphabetical):

March
April
August
November
December

Is there a simple way to do this without doing multiple if's? (Which doesn't allow you to sort by month)

ifelse({month}=1,"Jan",
ifelse({month}=2,"Feb",
ifelse({month}=3, "Mar",
ifelse({month}=4, "Apr",
ifelse({month}=5, "May",
ifelse({month}=6, "Jun",
ifelse({month}=7, "Jul",
ifelse({month}=8, "Aug",
ifelse({month}=9, "Sep",
ifelse({month}=10, "Oct",
ifelse({month}=11, "Nov",
ifelse({month}=12, "Dec",
"Error"))))))))))))

Solution

  • If your data has a column which is date (object) as your source then you can add a new calculation column that formats the date as 3 letter abbreviation.

    If your data is only strings add a new calculation column that uses the string to calculate an actual date.

    Sort the table on the date column and just hide that column if you like....This should display just the months in the correct order.

    I think parseDate() is the function you want to use to do this.

    https://docs.aws.amazon.com/quicksight/latest/user/parseDate-function.html