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?
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:
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โ)
I just did a test, to see if the substitute would preserve the list nature of things: yes it did.
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))
nope, cuz A1 would have a list in it like 1,2,5 for example lol
or the other way around:
@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!!
User | Count |
---|---|
37 | |
30 | |
29 | |
20 | |
18 |