【问题标题】:SSRS alternating 1000 separators with Number FormatSSRS 交替使用数字格式的 1000 个分隔符
【发布时间】:2021-08-28 05:09:14
【问题描述】:

我正在 Microsoft Report builder 中创建一个报告,据我所知,它在其表达式中使用了 MS Visual Basic,但我目前遇到了一个奇怪的数字格式问题:

由于某些未知原因,要求将数字(范围从 10.00 到 10,000,000,000.00+)格式化如下:10.000,000.000,00 - 因此交替使用 1000 个分隔符和逗号作为小数点分隔符。较小的数字显然会有较少的分隔符,但它们的顺序不会改变。

有没有办法使用格式函数来做到这一点,或者我必须使用 switch 和 substring 函数来制作某种手动怪物?

【问题讨论】:

  • 没有直接格式化字符串来实现这个

标签: reporting-services format reportbuilder ms-reports


【解决方案1】:

您可以使用自定义代码来创建格式化字符串

Public Function FormatNumber( num As Decimal) As String

Dim s1 As String
Dim s2 As String

' Format integer part using chars a and b
s1 = Format(  num\1, "###a###b###a###b###" )

' Remove unwanted a and b characters from begining

While s1(0) = "a" Or s1(0) = "b" 
s1 = Right(s1,Len(s1)-1)
End While

' Replace a and b characters
s1 = s1.Replace("a",",")
s1 = s1.Replace("b",".")

' Take decimal part and format it as two digits
s2 = Format ( ((num Mod 1)*100) \ 1, "00" )

Return s1 + "," + s2

End Function

现在在你的领域使用以下表达式

=Code.FormatNumber(Fields!val.Value)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多