9

Is there a different way to join/concatenate values from 2 single line columns into a 3rd column other than the way below?

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "=[$Text1] + ' and ' + [$Text2]"
}

I do not want to use a calculated column for this.

Columns are Text1, Text2 and Text3 is the one being formatted.

1 Answer 1

14

Yep, your alternative to an inline expression is this for concatenating values:

{
  "elmType": "div",
  "txtContent": {
    "operator": "+",
    "operands": [
      "[$Duration]",
      " ",
      "[$DurationUnits]"
    ]
  }
}

or also

{
    "elmType": "div",
    "txtContent": "=[$Duration] + ' ' + [$DurationUnits]"
}

Output (example):

8 hour(s)

2
  • 2
    Great answer, I'd also add that you can do this online with a single line like this: "txtContent": "=[$Duration] + ' ' + [$DurationUnits]" Also, worth mentioning is that unlike in calculated columns, both of these fields need to be present in the view in order to access their values using list formatting. Commented Jun 7, 2019 at 13:20
  • 1
    The single line version doesn't work on my end, the other option does work Commented Mar 5, 2020 at 9:47

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.