Change the delimiter of the last instance of a list variable to ", and"

Scenario 1:
the list value is more than one instance:
A, B, C, D
the output I want would be:
A, B, C, and D

Scenario 2:
the list value is just one instance:
A
the output I want would be:
A

Can anyone please suggest a solution to this? Thank you so much.

hello @Nicole , welcome to the community,

I noticed I responded to a question that resembled a lot your question, but your is also about a single item. I use ‘ListName’ to reference the A,B, C, D etc.

If(ListName.Count()=1,
ListName,
Format("{1} and {2}",
ListName.Slice(1,Lamb.Count()-1).List(),
ListName.Last()))

to understand the logic behind it a bit better:

Cheers, Christiaan

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.