I have a 2 sheet report and want SSRS to hide columns from sheet1 and sheet2 based on the time of day.
Steps and Issue: I added an expression to hide columns and data in sheet2. If the report runs after 12:00:00 PM all columns are displayed. The issue is when I schedule before 12:00:00 PM the columns are not hidden.
I added the following expression where if report is run prior to 12:00:00 PM local time hide else show.
I left out the date parameter since the report is only run 1x/month.
Sheet1: Hide columns
- Selecting column from tablix
- Right-Click choose 'Column Properties'
- Select 'Visiblity'
- Select 'Show or hide based on expression
- Added expression: =IIF(Globals!ExecutionTime <"12:00:00:00 PM",true,false)
Sheet2: Hide sheet
- Select rectangle where the tablix is placed
- Right-Click and select 'Rectangle Properties'
- Select 'Visiblity'
- Select 'Show or hide based on expression
- Added expression: =IIF(Globals!ExecutionTime <"12:00:00:00 PM",true,false)
Globals!ExecutionTimewill return the date and time that the report started execution, not just the time. Your expression compares with just a time so it will compare the default system date (or whatever it's called, it'll be something 1900-01-01) at 12:00:00 to your execution date/time so it will always appear as 'after' the time you specified.You can solve this very easily by using something like
Here we just extract the hour from the execution datetime and check if it's less than 12
Also note that as this will return a boolean, there is no need for the
IIF()