2016-12-14 10 views
2

私はこれを解決するために長い時間を費やしています。既存のソリューションをさまざまな問題に適応させる努力もうまくいきませんでした。SSRSルックアップセットの最大日付

私は、リストを返すために、それらを結ぶ、日付のリストを返すためにLookupSetを使用しています:

=Join(LookupSet(Fields!cPatSer.Value,Fields!cPatSer.Value,Fields!DDate.Value,"PatD")) 

私はそのリストから最新の日付を表示したいです。ここで私はこれまで試してみましたです:

  • MAX関数に包まれた上記の関数は(動作しないため、戻り文字列を参加)
  • カンマを探して結果の文字列を分割し、分割機能を使用します最大の機能
  • 上記の両方を行うことなく、次のよう最初のCDate関数とDateTime.Parseを使用してDateオブジェクトに出力を変換する...使用して、その後

    =(LookupSet(フィールズ!cPatSer.Value、フィールドに参加しましょう。 cPatSer.Value、CDate(Fields!DDate.Value)、 "PatD"))

    =参加(LookupSet(フィールズ!cPatSer.Value、フィールズ!cPatSer.Value、DateTime.Parse(フィールズ!DDate.Value)、 "PATD"))

誰もが任意のポインタを提供することができますしてください?

答えて

2

カスタムコードを使用して解決策を見つけました。 Oz Lockeは、整数データのさまざまな集計を行う関数を作成しました(以下のリンクを参照)。これを代わりに日付用に修正しました。レポートのセルにおけるその後

'Amended from Oz Locke's code: 
'https://github.com/OzLocke/SSRSAggLookup/blob/master/AggLookup.vb 
'Allows users to adjust the aggregation type of lookupsets in a cell 
Function AggLookup(ByVal choice As String, ByVal items As Object) 

'Ensure passed array is not empty 
'Return a zero so you don't have to allow for Nothing 
If items Is Nothing Then 
    Return 0 
End If 

'Define names and data types for all variables 
Dim current As Date 
Dim count As Integer 
Dim min As Date 
Dim max As Date 
Dim err As String 

'Define values for variables where required 
current = CDate("01/01/1900") 
count = 0 
err = "" 

'Calculate and set variable values 
For Each item As Object In items 

    'Calculate Count 
    count += 1 

    'Check value is a number 
    If IsDate(item) Then 

     'Set current 
     current = CDate(item) 

     'Calculate Min 
     If min = Nothing Then 
      min = current 
     End If 
     If min > current Then 
      min = current 
     End If 

     'Calculate the Max 
     If max = Nothing Then 
      max = current 
     End If 
     If max < current Then 
      max = current 
     End If 

     'If value is not a number return "NaN" 
    Else 
     err = "NaN" 
    End If 

Next 

'Select and set output based on user choice or parameter one 
If err = "NaN" Then 
    If choice = "count" Then 
     Return count 
    Else 
     Return 0 
    End If 
Else 
    Select Case choice 
     Case "count" 
      Return count 
     Case "min" 
      Return min 
     Case "max" 
      Return max 
    End Select 
End If 
End Function 

、この表現を使用します:レポートのCode財産、この中にペーストで

ため

=code.AggLookup("max", LookupSet(Fields!cPatSer.Value,Fields!cPatSer.Value,Fields!DDate.Value,"PatD")) 

https://itsalocke.com/aggregate-on-a-lookup-in-ssrs/ https://github.com/OzLocke/SSRSAggLookup/blob/master/AggLookup.vb

+0

謝罪をコメントをするのにとても時間がかかりましたが、これは大きな助けとなりました。ありがとうございました! –