We have ssrs 2008 r2 rdls. I open an SSRS report and keep it open in my browser for more than 30 mins. If I now click any drill downs either through an action or goto report. I don't want the report get me that info. It should state that the report is expired.
Is there a solution already available . Do future version SQL server have a solution for this.
There not a built in way to do this natively in SSRS.
I haven't heard of anyone asking about a requirement like this before so I doubt that there's something already in the works to add it.
I don't know JavaScript enough to know whether or not you can add logic to the JavaScript URL to where it would create a blank link or link to a Page Expired page.
="javascript:void(window.open('https://na5.salesforce.com/','_blank'))"
You could create a hidden datetime parameter on the main report and set its default value to the current time: =Now(). Let's call this parameter #MainReportRuntime.
Make this same hidden parameter on your subreports and pass #MainReportRuntime through to the subreports.
Modify the SQL of the subreport to only return data when the date is within half an hour of the main report runtime and add the report expiry message when it is greater than half an hour old:
SELECT SomeField
FROM SomeTable
WHERE #MainReportRuntime >= DateAdd(mi, -30, Current_Timestamp)
UNION ALL
SELECT 'Report has expired - please rerun report to get current data'
WHERE #MainReportRuntime < DateAdd(mi, -30, Current_Timestamp)
Related
I need to make a report of all patients who had an appointment last week. This report will be added to another excel with some lookups and then put into Power BI because we don't have way of connecting our sql server.
I'm trying to reduce the amount of manual work I have to do by instead of using parameters with dates, adding a dynamic date.
I have tried using TODAY, CURRENT_DATE and they all come back with an error.
I just need it to give me data for 7 days prior to the current date
Any help would be greatly appreciated.
This is what the first part looks like:
SELECT
PM.vwApptDetail.Patient_Last_Name
,PM.vwApptDetail.Patient_First_Name
,PM.vwApptDetail.Patient_DOB
,PM.vwApptDetail.Appointment_DateTime
,PM.vwApptDetail.Appt_Type_Desc
,PM.vwApptDetail.Resource_Desc
,PM.vwApptDetail.Status
FROM
PM.vwApptDetail
WHERE
PM.vwApptDetail.Appointment_DateTime >
I ended up using:
WHERE Appointment_DateTime BETWEEN GETDATE() AND DATEADD(DAY, -7, GETDATE())
and it seems to have worked.
I am using the following query (when connecting to SQL database in Direct Query mode) to get appointments for the previous 12 months:
Table.SelectRows(dbo_ReportAppointmentsView, each Date.IsInPreviousNMonths([Date], 12))
It was working perfectly fine and was generating SQL query with where clause like:
where convert(date, [_].[Date]) >= convert(datetime2, '2015-11-01 00:00:00') and convert(date, [_].[Date]) < convert(datetime2, '2016-11-01 00:00:00'))
The problem is that when current month changed (November -> December) it is still generating SQL query with exactly the same dates.
I expected the dates be '2015-12-01' and '2016-12-01' to display data for previous 12 months.
It helps to press "Refresh" button in Power BI desktop but it is clearly not a maintainable solution if I want the report to automatically display correct data.
Is it a bug or expected behavior?
This behaviour appeared to be a known issue.
The behavior you're observing when using Direct Query against SQL is a
known issue with the legacy Direct Query architecture. We will be
moving SQL Direct Query to a new architecture over the next few
months, but until then there's unfortunately no workaround besides
manually refreshing.
If by saying "Direct Query mode" you mean "Native Query", then it is not best practice and should be avoided.
Other than that, try replacing Date.IsInPreviousNMonths with something like
LocalDT = Date.LocalNow() //May be replaces with desired #date(2016, 11, 25) and likewise
ThisMonthStart = #date(Date.Year(LocalDT), Date.Month(LocalDT), 1),
CompareDate = Date.AddMonths(ThisMonthStart, -12),
Table.SelectRows(dbo_ReportAppointmentsView, each [Date] >= CompareDate)
and see if it generates another dates in query.
If you indeed using Native Query, then perhaps this is a bug linked to this mode.
All functions that check for a date(time) in a certain period relative to the system date(time), should be interpreted as ".... at last refresh".
In my opinion this is expected behavior, even when running is Direct Query mode: the latest data is accessed with the query definitions at last refresh.
My suggestion would be create a field in your SQL database with the current system date(time) (or just use it if it is already available) and select your data based on the value from that field.
Using Crystal Reports version 8. Trying to restrict data retrieved based on date range provided by the user.
Here is the formula I am trying to use in the Select Expert:
{Query.current0} <> 0.00 and
{Query.status} in ["PIF", "SIF"] and
{Query.closed} >= DateTime ({?Start}, Time (00,00,00)) and
{Query.closed} <= DateTime ({?End}, Time (23,59,59))
When I click the error checking button, CR gives the error "A date-time is required here" and puts the cursor at the end of the second line after the "and".
I have confirmed both {?Start} and {?End} are Date parameters and they do have data in them. {Query.closed} is a datetime in the original database, and if I remove the {Query.closed} date restrictions, the report runs fine (it just pulls all the data in the database!).
Oddly enough, I have another Crystal Report that runs just fine using this formula in the Select Expert:
{Collect2000Log.LogWhen} >= DateTime ({?FromDate}, Time (00,00,00)) and
{Collect2000Log.LogWhen} <= DateTime ({?ToDate}, Time (23,59,59))
In both reports, the parameters involved are Date parameters, and both {Collect2000Log.LogWhen} and {Query.closed} are datetime fields. One major difference is the PIF/SIF report (the one with the errors) is built on a saved Crystal SQL Query and the one without errors was not.
Can anyone help me spot what I am missing?
After further exploration, I'm not sure what the actual issue was, however I re-created the report WITHOUT the use of Crystal SQL Queries and it is now pulling data just fine. Would appreciate knowing the details if anyone can explain, but for now mystery is solved!
I've been stuck on this issue for most of this morning...I am trying to work through a display issue with my SSRS report regarding my "As of Date". The data behind this report is loaded nightly, meaning the data is only as good as yesterdays actual date. My problem is that my report currently defaults the parameter to =#AsOfDate = Today().
However, in order for this to be accurately reflected, whenever a User wants to change the date on this report, I would need the "As Of Date" to always reflect yesterday. So if we ran this report for today 3/7/16, the Data behind the report is from 3/6/16 thus, the report should show "As of" 3/6/2016, and if they selected 2/29, on View Report, it should show As Of 2/28/16, etc.
My SQL statement in the report is using a column from my report table called CurrentDate which just holds the nightly load date. It states ...
WHERE #AsofDate = CurrentDate
Does anyone have any idea how I could accurately script this so that a User can always know that the data is from the night before?
Thank you!,
Try setting your AdOfDate to the default value for yesterday (calculated):
#AsOfDate = DateAdd(DateInterval.Day, -1, Today())
Otherwise, you could set your SQL query to do the same
WHERE AsOfDate = DateAdd(d, -1, GetDate())
I Use DataCollection on SSMA\Object Explorer\Management\DataCollection in 2 day ago.
But each time I get report from Data Collection, no data available to display. The following image is a sample Server Activity History report of data collection reports.
this query will confirm if a snapshot was actually taken on that date: (change the name of your Data Management Warehouse)
SELECT [snapshot_time_id]
,[snapshot_time]
FROM [DATA_MANAGEMENT_WAREHOUSE].[core].[snapshot_timetable_internal]
WHERE CAST(snapshot_time AS DATE) = CAST('2014-06-19' AS DATE)
if there is no result set, run without the filter to confirm when the snapshots first started and what the interval is.
SELECT [snapshot_time_id]
,[snapshot_time]
FROM [DATA_MANAGEMENT_WAREHOUSE].[core].[snapshot_timetable_internal]
Then, if you have no results, check to see if the Agent service is on. I believe it could be related to one of these things.
EDIT: added another query to check for wait stats.
SELECT [wait_type]
,[waiting_tasks_count]
,[wait_time_ms]
,[signal_wait_time_ms]
,[collection_time]
,[snapshot_id]
FROM [DATA_MANAGEMENT_WAREHOUSE].[snapshots].[os_wait_stats]