JSON Help: How to add text/prefix to the value in a calculated column (SharePoint List)

Ramey, Micah 5 Reputation points
2023-03-31T18:50:46.41+00:00

Hello!

I've created a column for 'Net Weight (oz)'. When the user enters oz, another calculated column returns lbs. I've successfully created the calculated column for lbs titled, 'Net Weight (lb)'. With the returned value in lbs, I would like to add "lbs" as the unit of measure for that column. I'm unsure of how to do this using JSON? When i add text content in JSON, the calculated value disappears.


{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "g"
}
Microsoft 365 and Office | SharePoint | Development
{count} votes

2 answers

Sort by: Most helpful
  1. Ed Harris 25 Reputation points
    2023-03-31T23:00:36.28+00:00

    You’re in luck, because I do know JSON. I looked at your example and I believe the following is what you need to properly combine the text together.

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

  2. Yanli Jiang - MSFT 31,596 Reputation points Microsoft External Staff
    2023-05-04T09:24:06.77+00:00

    Hi @Ramey, Micah ,

    I have tried the solution @Ed Harris offers, and it worked fine.

    05043

    Could you please share the situation after you try it?


    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.