JSON formatting Sharepoint column

K D 1 Reputation point


I have a Sharepoint column with about 30 different values. These values have 11 digits.

I want to replace these 11 digit values with letters via Json formatting.

01234567890 = ABC
12345678901 = AAA
23456789012 = BBB

I manage to do this for a single value, here is the code I use:

"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=replace(@currentField, '01234567890', 'ABC')"

However, I also want to replace the other values but I can't find the good "code" (I don't know Json at all).

Could someone please help me?

Thanks in advance,

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,012 questions
{count} votes

2 answers

Sort by: Most helpful
  1. K D 1 Reputation point

    Is it possible that this is not feasible?

    0 comments No comments

  2. Yanli Jiang - MSFT 22,656 Reputation points Microsoft Vendor

    Hi @K D ,

    Your needs can be accomplished.
    You can use JSON code as below:

    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "=if(@currentField =='01234567890','ABC',if(@currentField =='12345678901','AAA','BBB'))"


    The result is shown below:



    If you have 30 different values, you can stack the if statements on the basic of my code.

    Yanli Jiang


    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.