Subscribing to a report with different default parameters - reporting-services

I have created a report in VS2013. I have also created a Stored procedure that returns a dataset that works out Last_week_start, Last_week_finish, Last_month_start, Last_month_finish etc. I have done this so users can subscribe to these reports and get them emailed to them on a Monday for the weekly and on the 1st on the month for the monthly reports. Do I have to create separate reports for the weekly and monthly reports with different default parameters? ie Audit Report (weekly) and Audit Report (monthly) and maintain 2 reports or is there a more dynamic way to do this

The way I have handled reports that I want to allow end users to subscribe to, and have the default date values vary depending on whether subscription was a daily, weekly, or monthly one, is to have an extra parameter that makes this possible.
The parameter I add to the report is one I call Period (or Report Period), and it has to be the first parameter in the report, or at least listed before the date parameters. The only values in the dropdown for this parameter are Daily, Weekly, and Monthly (or whatever is applicable). These can be whatever you need. Enter these manually as value options in the parameter in the report, since they are not expected to change very often. Based on what the end user chooses for this parameter when creating a subscription, the default date values change. This is done via an expression in the default value for the date parameters that evaluates the value chosen from the Period dropdown.
So, if the end user wants a daily subscription, they choose Daily from the Period parameter dropdown, and the default values for the start and end date parameters change to only include the prior day. If they choose Weekly, the start and end date parameters change to only include the prior week, and so on.
Here is an example for the start date parameter default value expression.
=Switch(Parameters!Period.Value = "Daily" , DateAdd(DateInterval.Day, -1, Today),
Parameters!Period.Value = "Weekly" , DateAdd(DateInterval.WeekOfYear, -1, DateAdd(DateInterval.Day, -(DatePart(DateInterval.Weekday, Today, 0, 0)-1), Today)) ,
Parameters!Period.Value = "Monthly" , DateAdd(DateInterval.Month, -1, DateAdd(DateInterval.Day, -(DatePart(DateInterval.Day, Today, 0, 0)-1), Today)))
For the end date parameter…
=Switch(Parameters!Period.Value = "Daily" , Today,
Parameters!Period.Value = "Weekly" , DateAdd(DateInterval.Day, -(DatePart(DateInterval.Weekday, Today, 0, 0)), Today) ,
Parameters!Period.Value = "Monthly" , DateAdd(DateInterval.Day, -(DatePart(DateInterval.Day, Today, 0, 0)), Today))
Warning!! Changing the Period value either in the report designer (preview), or online, will not cause the date values to automatically change right before your eyes. It will while creating (and thus executing) a subscription, however. I have never looked into why this is.
One report, dynamic date ranges based on a parameter.
Give it a try.

Related

Updating report parameters for dates based on list

Updating report parameters based on parameter selection? (SSRS)
the above seems to be applicable on list based parameters.
But how do we apply for Dates: say the requirement will be
if i create a list parameters for This day,This week,This month etc. the Start date should change based on earlier selections.
How do we acheive this?
You can set your list parameter to be of type integer, then set available values to be:
Then in your date parameter, set the default value to be along the lines of:
=switch(Parameters!ReportType.Value = 1, dateadd(dateinterval.day, -1, Today()), Parameters!ReportType.Value = 2, DateAdd(DateInterval.Day, 2-WeekDay(Today()), DateAdd(DateInterval.Day, -7, Today())), 1=1, dateadd(dateinterval.day, -1, Today()))
This checks the value of the previous parameter and sets the default start date based on that (weekly or daily). The final condition in the switch is 1=1 - this is always true, so is the equivalent to an else condition. It's not required, I just like it in case something weird happens and they manage to get there.
Note
If you select one of the values from the first parameter (e.g. "Daily") and the default values for the date parameter(s) change, changing the first parameter to "Weekly" will not update the date parameter. This is a known issue with cascading parameters - the only way to change them at that point is to either do it manually or refresh the report.

Need to set a date parameter on an SSRS subscription

I have a report in SSRS that takes a single date as a parameter. What I want is for that report to have a subscription that uses the Saturday of two weeks ahead as the date (i.e., Monday 7/4 would give Saturday 7/16). How can I do this in the subscription? Looks like I can't do a formula in the parameter.
You have to set the default parameter value in the report, not in the subscription. An expression to use in the default for the date parameter would look something like this. There both add 2 weeks to the current date.
=DataAdd(DateInterval.WeekOfYear, 2, Today)
or
=Today.AddDays(14)
The default values can be set using the Report Parameters Properties dialog in the report designer. Just double-click on the parameter you want to change and the dialog will open.

subscription contains parameter values that are not valid

I have a report with begin date and end date parameters and is specifically meant for subscription that should serve 2 types of subscriptions:
1, One for previous fiscal week -->Begin date is first day of previous fiscal week and end date is last day of previous fiscal week.
2, One for previous day -->Begin date is previous day and end date is also previous day.
Dataset Datefields:
This is the dataset query results for both date parameters available and default values.
When I create subscription for previous day it only runs that day...after midnight that day, begin date and end date parameter values are blank and the subscription fails with a status message "The subscription contains parameter values that are not valid" values.
Subscription created for previous fiscal week is good for a week until the values previous fiscal week start and end dates change.
You are using a dataset for defaults and values for date parameters, which probably isn’t the best approach.
The way I have handled reports that I want to allow end users to subscribe to, and have the default date values vary depending on whether subscription was a daily, weekly, or monthly one, is to have an extra parameter that makes this possible.
The parameter I add to the report is one I call Period (or Report Period), and it has to be the first parameter in the report, or at least listed before the date parameters. The only values in the dropdown for this parameter are Daily, Weekly, and Monthly (if applicable). These can be whatever you need. Enter these manually as value options in the parameter in the report, since they are not expected to change very often. Based on what the end user chooses for this parameter when creating a subscription, the default date values change. This is done via an expression in the default value for the date parameters that evaluates the value chosen from the Period dropdown.
So, if the end user wants a daily subscription, they choose Daily from the Period parameter dropdown, and the default values for the start and end date parameters change to only include the prior day. If they choose Weekly, the start and end date parameters change to only include the prior week, and so on.
Here is an example for the start date parameter default value expression.
=Switch(Parameters!Period.Value = "Daily" , DateAdd(DateInterval.Day, -1, Today),
Parameters!Period.Value = "Weekly" , DateAdd(DateInterval.WeekOfYear, -1, DateAdd(DateInterval.Day, -(DatePart(DateInterval.Weekday, Today, 0, 0)-1), Today)) ,
Parameters!Period.Value = "Monthly" , DateAdd(DateInterval.Month, -1, DateAdd(DateInterval.Day, -(DatePart(DateInterval.Day, Today, 0, 0)-1), Today)))
For the end date parameter…
=Switch(Parameters!Period.Value = "Daily" , Today,
Parameters!Period.Value = "Weekly" , DateAdd(DateInterval.Day, -(DatePart(DateInterval.Weekday, Today, 0, 0)), Today) ,
Parameters!Period.Value = "Monthly" , DateAdd(DateInterval.Day, -(DatePart(DateInterval.Day, Today, 0, 0)), Today))
Warning!! Changing the Period value either in the report designer (preview), or online, will not cause the date values to automatically change right before your eyes. It will while creating (and thus executing) a subscription, however. I have never looked into why this is. I have other, less painful, things to fill my time.
Give this a try.

Report Builder 3.0 Updating Parameter Panel

I have a report that has StartDt, and EndDt as parameters. When a user leaves these blank, I default StartDt to yesterday, and EndDt to today. That works fine the the actual parameter send to SQL. But is there a way to update the SSRS Parameter Panel to show the user what dates were defaulted?
I know I could just make the parms required, but I'd rather default the dates like this so users can just put in there account(s) and move on.
Set the default value expressions for each date parameter using the standard date/time functions.
You can set today as:
=Today()
Yesterday as:
=DateAdd(DateInterval.Day, -1, Today())
See How to: Add, Change, or Delete Default Values for a Report Parameter for more details.
Edit after comments
Say you have the following parameters:
StartDt and EndDt are just set up as Date/Time:
Set the Default Values expression for each parameter using the expressions above, i.e. =Today() and =DateAdd(DateInterval.Day, -1, Today()):
Now, when you load the report for the first time the two parameters are already populated with the Default Values:
Users can then just leave the dates as the defaults as they're already set, or change them as necessary.

sql query to get a scheduled report to run for that curent month only

I have an SSRS 2005 report that has a dataset for to an Oracle database. The report that i have essentially just pulls all data back from an audit log. This report works perfectly fine and i have scheduled thi to run and send an email using the new subscription method within SSRS.
The only issue i have is i want the report to run on the last day of the month (its set up to do this alreday) and run the report based on that month only. Getting the report to run specifically for a month is what im unsure on? I though i would be able to set parameters within the report but these only enable my user to select a calendar date?
Is there a DATEADD or DATEPART type of function i can use to complete this task?
Regards
B
Best bet would be to set up a dynamic date default for the date patameter at the report level, and set up the subscription to use this default value, so whenever the subscription runs it would automatically have the appropriate date.
Probably the easiest thing to do is set the parameter as the current date, if that would work, e.g. something like =Today(). So that will be calculated whenever the subscription runs.
You can set the default value for whatever you need; first day of the current month, etc. You should able to set whatever value you need without too much trouble.
So for the first day of the month something like:
=DateSerial(Year(Today()), Month(Today()), 1).
Users running the report ad-hoc could just reset the parameter as required.
I'm assuming the report handles the amount of data to return correctly assuming the right data parameter is sent.
2 Parameters #DateFrom and #DateTo
Default Value for #DateFrom that outputs the first day of the current month:
=DateAdd("d",-Day(Today())+1,Today())
Default Value for #DateTo that outputs the last day of the current month:
=DateAdd("d",-Day(Today())+1,DateAdd("m",1,Today()))