資料在SQL資料庫中是獨立的行。它已經被分組,然后串聯起來,得到這個格式的表格。然而,我需要為成熟度值形成一個范圍。
我已經嘗試了一些想法,比如。 =IIF(Fields! Pivot_2.Value.Contains(" Years")), "30 Years", Nothing)
以及在資料集屬性中使用計算欄位,比如。 =Split(Fields! Pivot_2.Value,",")(0)
但是不確定如何擴展它以獲得這個單元格的范圍。
期望的輸出。抓取最大的年數和最小的天數。如果沒有天數,那么最小的是月數。就像30年-1天一樣。
uj5u.com熱心網友回復:
你可以使用以下的自定義代碼
Public Function ParsePeriods(ByVal str As String) As String String
Dim iMin As Integer = 1000000[/span]。
Dim iMax As Integer = - 1
Dim sMin As String = ""
Dim sMax As String = ""
' 用數字替換文本,使之具有可比性
str = Replace(str, " years", "0000")
str = Replace(str, " year", "0000")
str = Replace(str, " months", "00")
str = Replace(str, " month", "00")
str = Replace(str, " days", "" )
str = Replace(str, " day", "")
' 分割字串元素并回圈得到最小和最大值。
Dim strArr() As String = str.Split(", ")
For Each elements As String In strArr
If Cint(element) < iMinThen
iMin = Cint(Element)
結束 若
If Cint(element) > iMax 然后
iMax = Cint(Element)
結束 若
下一步 下一步
' 使用整數min和max值來創建min和max字串。
If iMin < 100 然后
sMin = Cstr(iMin) & " day(s)"。
ElseIf iMin < 10000.
sMin = Cstr(iMin/100) & " month(s)"
Else
sMin = Cstr(iMin/10000) & " year(s)"
結束 若
If iMax < 100 Then
sMax = Cstr(iMax) & " day(s)"/span>
ElseIf iMax < 10000
sMax = Cstr(iMax/100) & " month(s)"
Else
sMax = Cstr(iMax/10000) & " year(s)"
結束 若
Return Cstr(sMin) & " - "/span> & Cstr(sMax)
End Function[/span
現在你可以使用下面這樣的運算式來呼叫自定義代碼
= Code.ParsePeriods( ReportItems! MaturityValue.Value )
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/325300.html
標籤:


