Sorting my months in order of month NOT alphabetically

I am having trouble putting my dates into a month (1/2/2019 ----->>> January). Then sorting the list by month order (Not in alphabetical order). I created a virtual column โ€œMonthโ€. I used this to switch the date format to a month:

SWITCH(
MONTH(TODAY()),
1, โ€œJanuaryโ€,
2, โ€œFebruaryโ€,
3, โ€œMarchโ€,
4, โ€œAprilโ€,
5, โ€œMayโ€,
6, โ€œJuneโ€,
7, โ€œJulyโ€,
8, โ€œAugustโ€,
9, โ€œSeptemberโ€,
10, โ€œOctoberโ€,
11, โ€œNovemberโ€,
12, โ€œDecemberโ€,
โ€œโ€
)

This did not allow me to sort in order per month.

I then tried this: (on my virtual column and the actual date column)
INDEX(
LIST(
โ€œJanโ€, โ€œFebโ€, โ€œMarโ€, โ€œAprโ€, โ€œMayโ€, โ€œJunโ€,
โ€œJulโ€, โ€œAugโ€, โ€œSepโ€, โ€œOctโ€, โ€œNovโ€, โ€œDecโ€
),
MONTH(TODAY())
)

Still will not sort in month order.

Any ideas?
Thanks in advance

Solved Solved
0 5 2,931
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

For the virtual column, youโ€™ll need to prefix the month name with a number that will sort as desired:

CONCATENATE(
  MONTH([invoice_date]),
  "-",
  SWITCH(
    MONTH([invoice_date]),
    1, โ€œJanuaryโ€,
    2, โ€œFebruaryโ€,
    3, โ€œMarchโ€,
    4, โ€œAprilโ€,
    5, โ€œMayโ€,
    6, โ€œJuneโ€,
    7, โ€œJulyโ€,
    8, โ€œAugustโ€,
    9, โ€œSeptemberโ€,
    10, โ€œOctoberโ€,
    11, โ€œNovemberโ€,
    12, โ€œDecemberโ€,
    โ€œโ€
  )
)

or:

CONCATENATE(
  MONTH([invoice_date]),
  "-",
  INDEX(
    LIST(
      โ€œJanโ€, โ€œFebโ€, โ€œMarโ€, โ€œAprโ€, โ€œMayโ€, โ€œJunโ€,
      โ€œJulโ€, โ€œAugโ€, โ€œSepโ€, โ€œOctโ€, โ€œNovโ€, โ€œDecโ€
    ),
    MONTH([invoice_date])
  )
)

View solution in original post

5 REPLIES 5

Steve
Platinum 4
Platinum 4

For the virtual column, youโ€™ll need to prefix the month name with a number that will sort as desired:

CONCATENATE(
  MONTH([invoice_date]),
  "-",
  SWITCH(
    MONTH([invoice_date]),
    1, โ€œJanuaryโ€,
    2, โ€œFebruaryโ€,
    3, โ€œMarchโ€,
    4, โ€œAprilโ€,
    5, โ€œMayโ€,
    6, โ€œJuneโ€,
    7, โ€œJulyโ€,
    8, โ€œAugustโ€,
    9, โ€œSeptemberโ€,
    10, โ€œOctoberโ€,
    11, โ€œNovemberโ€,
    12, โ€œDecemberโ€,
    โ€œโ€
  )
)

or:

CONCATENATE(
  MONTH([invoice_date]),
  "-",
  INDEX(
    LIST(
      โ€œJanโ€, โ€œFebโ€, โ€œMarโ€, โ€œAprโ€, โ€œMayโ€, โ€œJunโ€,
      โ€œJulโ€, โ€œAugโ€, โ€œSepโ€, โ€œOctโ€, โ€œNovโ€, โ€œDecโ€
    ),
    MONTH([invoice_date])
  )
)

Ok. And use the virtual column to do this?

Neither worked. All it does is put everything under - October?

Also, am i suppose to do something with the original column - โ€œinvoice_dateโ€ to index the date format?

Ah, yes, thatโ€™s important! Iโ€™ve updated the instructions above to use [invoice_date] rather than TODAY(). Try that.

You are the man! That worked. Thanks again. You have helped me out with so much.

Top Labels in this Space