17

Is there a way to achieve this without adding a calculated item with this format = TEXT([Customer Number], "0") ??

I'm using sharepoint 2013.

2
  • Have you tried sp designer for changing xslt dataview ?. have a look this link and link Jul 7 '15 at 7:09
  • Warning: Many of the ways to get rid of the thousands separator will convert the value to text (calculated field will do this, too). Be aware, that this will change sorting to alphabetically instead of numerical!
    – Hinek
    Sep 27 '17 at 13:31
10

There are couple of approaches to achieve this:

  1. Using Client Side Rendering

    • Using CSR you can manipulate how your column data is visualized. But you'll need to manually put the JSLink everywhere.
  2. Use Text Column and do validation

    • You can use a text column instead of number and do a below column validation:

      =ISNUMBER([ColumnName]+0)
      
1
  • Need more information on how to do that ISNUMBER check. All it does is return a true or false, after all, and you still need to enter the formula that puts in the value you're trying to strip a comma from - where does that part go, relative to this?
    – vapcguy
    Nov 3 at 17:35
9

I added a JSON for the column formatting of the number column. Try the code below:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if(@currentField > 0,'', '')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block"
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
}
3
  • Welcome to the SharePoint StackExchange. User is using SharePoint 2013 and Column formatting is not supported in SharePoint 2013. Sep 24 '19 at 11:07
  • 1
    Thank you. I am unaware of such restriction.
    – panicdb
    Oct 8 '19 at 10:11
  • Typed this into my field exactly in a 2019 SP instance, using @currentField, currentField, @My_x0020_Field, and My_x0020_Field, but it didn't fix it. It is on a system that is detached from the internet, though, so I don't know if not being able to pull up that schema reference matters. I also thought maybe the "class": "=if(@currentField > 0,'', '')" line should've been "class": "=if(@currentField > 0,',', '')" (add in a comma between the first set of apostrophes), but that didn't work for any combination, either.
    – vapcguy
    Nov 3 at 17:48
2

Or use a workflow to write a Number value to another Text field.

Or do not use a Number field and make [Customer Number] a Text field.

formatting can be an issue still

1

with jQuery (or simple javascript selectors) remove them

var numberinput=$("inputid")
numberinput.val(numberinput.val().replace(/,/g,""))
2
  • Would this be placed on the list page? If so, would it look like this: <script src="ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"> </script> <script> var numberinput=$("COLUMN DISPLAY NAME") numberinput.val(numberinput.val().replace(/,/g,"")) </script> Oct 14 '16 at 21:49
  • select all column's cells by a selector like $('table tr td:nth-child(3)') and then look for text() or innerHtml and then replace it with clean value.
    – Iman
    Oct 15 '16 at 10:00
1

I've just got same problem with commas in a number field. I checked MS Docs and found this: NumberFormatInfo.NumberGroupSeparator Property The initial value of this property is derived from the settings in the Region and Language item in Control Panel.

I've changed EN region to German(Austria) and now there are no commas for me.

Not the best solution, but it makes sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.