Is it possible to add individual colors to concatenated text from other columns

Derek Kent 0 Reputation points
2024-07-03T19:35:37.12+00:00

Hello,

Basically, in my calculated column I have a concatenate function bringing first and last name together.

=CONCATENATE([FirstName]," ",[LastName])

But I have a request to have each column referenced a different color like so

User's image

Is this possible, How can I accomplish this?

Thank you for any help,

DK

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,264 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ling Zhou_MSFT 15,320 Reputation points Microsoft Vendor
    2024-07-04T02:27:48.59+00:00

    Hi @Derek Kent,

    Thank you for posting in this community.

    Unfortunately, there is no way to change the color of the text by the calculated formula alone. Calculated formulas are mainly used to calculate column values but are not responsible for the style of column values.

    We can use JSON formatting to change the style of column values. Rest assured, it only changes the display style of the column values, not the column values.

    1.Select your calculated column > format this column.

    User's image

    2.Select Advanced mode.

    User's image

    3.Copy the following JSON Code.

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "children": [
        {
          "elmType": "span",
          "txtContent": "[$FirstName]",
          "style": {
            "color": "#ff0000"
          }
        },
        {
          "elmType": "span",
          "txtContent": "[$LastName]",
          "style": {
            "padding-left": "4px",
            "color": "#00ff00"
          }
        }
      ]
    }
    
    

    Here is my test result:

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments