Sort Month Name

Hi!

I would like to find out if thereโ€™s any way to sort month name according to month order (Jan, Feb, Mar, Apr, โ€ฆ) instead of alphabetical order (Apr, Feb, Jan, Mar, โ€ฆ)?

Thank you!

Solved Solved
0 18 2,435
1 ACCEPTED SOLUTION

@App_Creator
If itโ€™s not a big deal for you, slightly change your SWITCH expression:

SWITCH(
MONTH([Date]),
1, โ€œ1-Janโ€,
2, โ€œ2-Febโ€,
3, โ€œ3-Marโ€,
4, โ€œ4-Aprโ€,
5, โ€œ5-Mayโ€,
6, โ€œ6-Junโ€,
7, โ€œ7-Julโ€,
8, โ€œ8-Augโ€,
9, โ€œ9-Sepโ€,
10, โ€œ10-Octโ€,
11, โ€œ11-Novโ€,
โ€œ12-Decโ€
)

View solution in original post

18 REPLIES 18

@App_Creator
May I ask where and how you are using that month names? And how you get them? With long date setting? Please elaborate.

Thanks LeventK.

I got the month names using switch expression and the names became Text. Hence sorting according to alphabetical order.

SWITCH(MONTH([Date]), 1, โ€œJanโ€, 2, โ€œFebโ€, 3, โ€œMarโ€, 4, โ€œAprโ€, 5, โ€œMayโ€, 6, โ€œJunโ€, 7, โ€œJulโ€, 8, โ€œAugโ€, 9, โ€œSepโ€, 10, โ€œOctโ€, 11, โ€œNovโ€, โ€œDecโ€)

I am using these month names to group a set of entries and sort in desending order according to the month in a table view.

Thank you!

@App_Creator
If itโ€™s not a big deal for you, slightly change your SWITCH expression:

SWITCH(
MONTH([Date]),
1, โ€œ1-Janโ€,
2, โ€œ2-Febโ€,
3, โ€œ3-Marโ€,
4, โ€œ4-Aprโ€,
5, โ€œ5-Mayโ€,
6, โ€œ6-Junโ€,
7, โ€œ7-Julโ€,
8, โ€œ8-Augโ€,
9, โ€œ9-Sepโ€,
10, โ€œ10-Octโ€,
11, โ€œ11-Novโ€,
โ€œ12-Decโ€
)

Thatโ€™s a great workaround! I will use that for the time being.

Thanks for your help, Leventk!

Youโ€™re welcome @App_Creator, my pleasure. Great to be helped of.

@LeventK

Any idea why the results are formatted as timedate with this solution? The date column this expression refers to is formatted as a date column yet the results of the SWITCH expression are formatted as timedate?

@Michael
Thatโ€™s basically because AppSheet interprets โ€œ1-JANโ€ string as a short format Joda Date and appends 12:00:00AM to it and therefore evaluates the string as โ€œ1st of January 12:00:00AMโ€, โ€œ2nd of February 12:00:00AMโ€, โ€œ3rd of March 12:00:00AMโ€ and so on. As @Aleksi mentioned check the type of your Virtual Column and change it to Text if not.

What happens if you change your column type to text?

@Aleksi Although I have changed the date column to be formatted as text: TEXT(DATE([TimeStamp])), the result is still formatted as a date and therefore the SWITCH expression still results as timedate. The switch expression column is also formatted as text.
@LeventK

Iโ€™m still struggling with the idea that there has to be a way to display just the name of the month (without the preceding number and hyphen) and still have it sorted by month. Can anyone think of a way to โ€œaliasโ€ a VC? Some sort of sort by โ€œthisโ€ but display โ€œthatโ€? This is an old thread, has this been solved somewhere else?

โ€œThisโ€ would be a Ref value and โ€œthatโ€ would be its label.

Yeah. I was thinking that Ref might be the way to go but then if iโ€™m using the label in any other view that will throw that off. Iโ€™m still wrapping my head around all of the possibilities with Ref/Labels. Iโ€™ve probably overbuilt this particular table and am trying to do too much with it. Should build in more smaller Ref tables. Iโ€™ll keep at it and see what I can figure out. Thanks for the reply!

This is a perfect example of when a read-only table is appropriate.
[ID] is your key column, with 1-12.
[Month] is your text label column.

I do this exactly but for day of the week, and for the exact same reason.

The problem is Appsheet. There is a bug here. it simply does not recognize that you have set the column set to โ€œtextโ€ when a Joda Date is present regardless of all we are doing.

I have been trying to solve this for years.

Huh?

Create a virtual column with Enum type and enum entries as month names in order โ€˜Janโ€™, โ€˜Febโ€™, โ€˜Marโ€™ then use formula and switch statement to convert your date to month exactly like your enum. Then sort ascending and descending. It should work as expected.

Hi!

I was trying to solve that.

Your answer was simple, short and the Best Option

Brandonch2_0-1674025588253.png

๐Ÿ˜‰

Hi,

do you think i could solve my similar issue i'm having with this scenario ?

If yes, how ?

 

I've a table view that is grouped by Date 27/3/2023

Group.png

I'd like to show Date in my native language (italian) as Lunedรฌ 27 marzo 2023

as i've done elsewhere (i.e. in detail views)

using 2 virtual tables VTGiornoSettimana and VTMese

CONCATENATE ([VTGiornoSettimana], " ", TEXT([DATA], "d"), " ", [VTMese], " ", TEXT([DATA], "yyyy"))

How to achieve the same result in Table view leaving the grouping by date but changing date with my italian string concatenation ?

 

Top Labels in this Space