Chris Perry
Chris Perry

Reputation: 43

SSRS How do I rotate between reports in a slideshow manner?

I have been tasked with creating a dashboard to be displayed on TV monitors. This dashboard has 5 different charts that need to be displayed in a slideshow manner - in other words, one chart at a time, rotating to the next over a timed interval.

I used a solution posted on here with the visibility property =IIf(Second(Now()) >= 48 AND Second(Now()) <= 60, False, True) and so on with the report auto-refreshing at 12 second intervals.

However, my manager came back to me with the feedback that 12 seconds was too short of an interval, and that he would like to see each report for 20 seconds before it is rotated to the next one.

Does anyone have any ideas on how to make this possible?

Thanks so much.

Upvotes: 4

Views: 1585

Answers (2)

Jeffrey Stines
Jeffrey Stines

Reputation: 1

I have expanded on Ian Preston's solution with custom code. I basically wanted to make the solution fully expandable.

Use this in the Row Visibility Expression: =Code.SubReportHidden(RowNumber("Tablix1"), CountRows("Tablix1"), Parameters!ReportRefresh.Value, Now())

This is a custom parameter to change the refresh on the fly. You will also need to reference it in the Reports AutoRefresh property.

Parameters!ReportRefresh.Value

Add this to your reports Custom Code:

Public CurrentTimeInSeconds As Long
Private MinCycleRange As Long
Private MaxCycleRange As Long
Private PageCount As Integer
Private Page As Integer
Private FullCycle As Long
Private CurrentTime As DateTime

Public Function SubReportHidden(ByVal page As Integer, ByVal pageCount As Integer, 
  ByVal interval As Long, ByVal now As DateTime) As Boolean

If page.Equals(0) Then Throw New ArgumentOutOfRangeException("page")
If pageCount.Equals(0) Then Throw New ArgumentOutOfRangeException("pageCount")
If interval.Equals(0) Then Throw New ArgumentOutOfRangeException("interval")

Me.PageCount = pageCount
Me.Page = page
FullCycle = interval * pageCount
CurrentTime = now
SetCurrentTimeInSeconds()

SetMaxCycleRange()
SetMinCycleRange()

Dim visable As Boolean = True
If InRange() Then
  visable = False
End If
Return visable
End Function

Private Function InRange() As Boolean
Dim insideRange As Boolean = False
If CycleProgressPercent() > MinCycleRange AndAlso CycleProgressPercent() <= 
  MaxCycleRange Then
  insideRange = True
End If
Return insideRange
End Function

Private Function CycleProgressInSeconds() As Long
  Return CurrentTimeInSeconds Mod FullCycle
End Function

Public Function CycleProgressPercent() As Integer
  Return CInt(CycleProgressInSeconds() / FullCycle * 100)
End Function

Private Sub SetCurrentTimeInSeconds()
  CurrentTimeInSeconds = DateDiff(DateInterval.Second, DateTime.Today, CurrentTime )
End Sub

Private Sub SetMinCycleRange()
  MinCycleRange = CLng(((Page - 1) / PageCount) * 100)
End Sub

Private Sub SetMaxCycleRange()
  MaxCycleRange = CLng(((Page / PageCount) * 100))
End Sub

I have taken the time to rewrite the code as well, check out my GitHub for a testable solution. GitHubSSRS_Item_Cycle_Demo

Upvotes: 0

Ian Preston
Ian Preston

Reputation: 39566

You want to move from a 60 second cycle to a 100 second cycle.

Based on your existing code, you could use something like:

=IIf(DateDiff(DateInterval.Second, Today(), Now()) Mod 100 >= 80
    AND DateDiff(DateInterval.Second, Today(), Now()) Mod 100 <= 99
  , False
  , True)

You get the 100 second cycle by taking the number of seconds since the beginning of the day Modulo 100. You can then break this down into buckets of twenty in your expression instead of buckets of 12.

Upvotes: 2

Related Questions