0

I'm trying to centre the data in my SharePoint List's currency columns (Unit Price, Origination and Delivery Cost). I found an answer that supplied some JSON code to add, which worked but changed my decimal places from 0.00 to 0.0 - is there an additional piece of code I need to prevent this from happening?

Here is the code I'm currently using:

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "='£' + '@currentField'", "style": { "display": "flex", "justify-content": "center", "align-items": "center" } } 

I have no code experience, so I am totally out of my comfort zone!

Any help will greatly appreciated!

2 Answers 2

0

For your txtContent, I would try '@currentField.displayValue'

Syntax reference here

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField.displayValue", "style": { "display": "flex", "justify-content": "center", "align-items": "center" } } 
2
  • Thank you - Although this added an extra £ sign. Could you please provide the whole code? Commented Dec 16, 2024 at 7:45
  • @KayleeBiddle if you are getting an extra £ you could try removing from your json. sample added above Commented Dec 16, 2024 at 8:45
0

Paul Lucas is right, we usually use @currentField to get the value of a column so that you don't lose the accuracy of the data. Please try use this JSON:

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "style": { "text-align": "center" }, "txtContent": "@currentField" } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.