Convert enum list of months to numbers

I have an enumlist with months ex. (Jan, Feb, Jun, Aug). I need a formula to convert them to a list of their numeric equivalents (1,2,6,9). Does anyone know of an elegant way to do this?

0 23 1,878
23 REPLIES 23

Hi @Glenn_Thorne Check out SWITCH or SUBSTITUTE

SWITCH([Month],
โ€œJanuaryโ€, 1,
โ€œFebruaryโ€, 2,
etcโ€ฆ

Yes, I get that but how to process all items in the list into another list??? Or can this work?

[MonthNum] = SWITCH([Month],
โ€œJanuaryโ€, 1,
โ€œFebruaryโ€, 2,
etcโ€ฆ

Is MonthNum a list of month numbers?

Yessir it is

No easy elegant fix here, youโ€™ll have to construct some formula to reconstruct the list.

substitute(substitute([MonthNum], 1, โ€œJanuaryโ€), 2, โ€œFebruaryโ€), etc

This is close. If I understand it properly, it will change the items in the current list rather than making a new list though. I never thought this would be so difficult actually lol

Completing this out, and putting {1,2,3,4,5,6,7,8,9,10,11,12} for a sample list (giving one example of every month) you get the following:
2X_f_fda2c4cd7efa52f58e57c427017635c362b9a23b.png
substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute(substitute({1,2,3,4,5,6,7,8,9,10,11,12}, 12, โ€œDecemberโ€), 11, โ€œNovemberโ€), 10, โ€œOctoberโ€), 9, โ€œSeptemberโ€), 8, โ€œAugustโ€), 7, โ€œJulyโ€), 6, โ€œJuneโ€), 5, โ€œMayโ€), 4, โ€œAprilโ€), 3, โ€œMarchโ€), 2, โ€œFebruaryโ€), 1, โ€œJanuaryโ€)

2X_3_3b245ef5696cab3767c0c5509dc1d57304625f8f.png

I just did a test, to see if the substitute would preserve the list nature of things: yes it did.
2X_8_84aa3a6e4afc784fc9778960b2b4d120e8e88169.png

thinking this but seems to have a syntax errorโ€ฆ

switch([Corporate Remit Months]
,1, โ€œJanuaryโ€
,2, โ€œFebruaryโ€
,3, โ€œMarchโ€
,4, โ€œAprilโ€
,5, โ€œMayโ€
,6, โ€œJuneโ€
,7, โ€œJulyโ€
,8, โ€œAugustโ€
,9, โ€œSeptemberโ€
,10, โ€œOctoberโ€
,11, โ€œNovemberโ€
,12, โ€œDecemberโ€
, โ€œErrorโ€)

is that a list or a number? You canโ€™t use a list in a switch like this.

its a list. I want to convert a list of month numbers to equivalent list of month textโ€™s

substitute

Now im lost

Maybe take a look at this help document? Check the โ€œMonth number to Name sectionโ€? https://help.appsheet.com/en/articles/2357278-index

Thats a great article Mike and will work for concerting one month number to text but I dont think it sheds light on how to concert a list of month numbers to month tests. I am doubting that it can be done.

g

Ahโ€ฆ different use case. Could do on the back end (if the list is in google sheets). Otherwise, the formula guru (@Steve) might have a suggestion.

Do you know the formula in google sheets?

If A1 has the month name in it, you could use something like this in cell B1:

=ARRAYFORMULA(MONTH(A1:A&1))
2X_a_a871b3025d70dd480bda30bd1baa821c7e6042c0.png

nope, cuz A1 would have a list in it like 1,2,5 for example lol

or the other way around:
2X_2_28ac534b8a8424ae61350176596c3f464b7c1320.jpeg

@Glenn_Thorne
You can try with this:

CONCATENATE(
	SPLIT(
		IFS(
			IN(1, [ENUMLIST]),"January,"
		)&
		IFS(
			IN(2, [ENUMLIST]),"February,"
		)&
		IFS(
			IN(3, [ENUMLIST]),"March,"
		)&
		IFS(
			IN(4, [ENUMLIST]),"April,"
		)&
		IFS(
			IN(5, [ENUMLIST]),"May,"
		)&
		IFS(
			IN(6, [ENUMLIST]),"June,"
		)&
		IFS(
			IN(7, [ENUMLIST]),"July,"
		)&
		IFS(
			IN(8, [ENUMLIST]),"August,"
		)&
		IFS(
			IN(9, [ENUMLIST]),"September,"
		)&
		IFS(
			IN(10, [ENUMLIST]),"October,"
		)&
		IFS(
			IN(11, [ENUMLIST]),"November,"
		)&
		IFS(
			IN(12, [ENUMLIST]),"December,"
		),
		","
	)
)

Went with Substtiute but I think this would work as well.

thx much

Bingo! Got this to work! Thanks much!!

Top Labels in this Space