-1

I would like to format a column, so that when a user selects multiple choices, each choice is displayed on a single line rather than separated by comma (,).

I'm looking to leverage JSON formatting for this.

New contributor
Andrew Streaman is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
0

Try using below JSON code on your choice field:

{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "div",
   "txtContent": "=join(@currentField, '\n')"
}

Official documentation: Use column formatting to customize SharePoint.

Reference for operators you can use in JSON formatting, JSON formatting - Operators.

How join() works:

join() takes 2 operands. The first is an array (multi-select person or choice field) and the second is the separating string.

Returns a string concatenation of the array values separated by the separating string.

Example for multi-select choice field:

"txtContent": "=join(@currentField, ', ')" --> This will result in Apple, Orange, Cherry (depending on the selected values)

Example for multi-select person field:

"txtContent": "=join(@currentField.title, '|')" --> This will result in Chris Kent|Vesa Juvonen|Jeff Teper (depending on the selected persons names).

  • This did the trick! Thank you!! – Andrew Streaman Oct 9 at 12:37
  • Welcome. glad it worked for you. Keep asking questions/doubts on SharePoint StackExchange. – Ganesh Sanap Oct 9 at 12:42
0

You can use this:

{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "div",
   "txtContent": "=join(@currentField, '\n'"
}

A little explanation:

join: takes 2 operands. The first is an array (multi-select person or choice field) and the second is the separating string. Returns a string concatenation of the array values separated by the separating string. - Only available in SharePoint Online

"txtContent": "=join(@currentField, ', ')" might result in "Apple, Orange, Cherry" (depending on the selected values)
"txtContent": "=join(@currentField.title, '|')" might result in "Chris Kent|Vesa Juvonen|Jeff Teper" (depending on the selected persons)
-1

As they suggested, use the code they provided on your choice field:

{
    "$schema":
    "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "=join(@currentField, '\n')"
 }

This works for me, the following is my test result:

enter image description here

Your Answer

Andrew Streaman is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.