简体   繁体   中英

How do I add thousand separators in default number format in ssrs?

I got a bunch of numbers in different unit. I need to add thousand commas separators without affecting the decimal values. I want the decimal values to display as it is. I want the number format in following way

  • 10000 ---> 10,000
  • 56789.125 ---> 56,789.125
  • 2000.1231 ---> 2,000.1231

From SSRS (right click text box-expression), specify this expression value:

=Format(Fields!ColumnName.Value, "#,###0.####")

This will format your number into maximum 4 digits on decimal point, depending on presence of decimal values after the point.

If you need to format number value from C# code before adding to SSRS, use:

String.Format("{0:#,###0.####}", ColumnName.ToString()); // assume ColumnName is your number variable here

Custom numeric formatting reference: https://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx

I found this to be the simplest way:

myInteger.ToString("N0")

Or you can do like so:

myInteger.ToString("#,##0.00");

Try This:

static string FormatNumber(int num)
 {    
    return num.ToString("#,0");
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM