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.
Related
I've done many a cascading param in SSRS but ALL have used datasets, passing in a param value into a query, this time I want to know if a date selection can be done using only expressions.
Periodtype parameter has a value list of 'Day' Or 'Quarter' (those are the labels, the values are "D" and "Q").
I've set the default values of the start and end dates via SSRS expression if periodtype value is "D" then set start and end date to be beginning and end of previous day and if "Q" then similar with previous quarter.
This works when you start up the report, changing the default period type (D or Q).
It won't allow the date to be calculated dynamically when changing the periodtype, can it be done without queries, using just params and expressions, thank-you?
If I've understood your question correctly, I think the issue is not so much to do with datasets, but a long standing issue with SSRS not refreshing parameters, or at least the defaults, even if you specify to always refresh it.
Typically you can force the update by changes the available values.
As an example ...
I set up 2 parameters, the first called PeriodType is a simple text parameter with two available values "Q" and "D", it also has a default value of "D"
The second parameter called StartDate is a Date/Time type.
The following three properties were all set to the exact same expression
Available Values: Specify Values - Label and Value properties
Default Values: Specify Values - Value property
Here is the expression which simply shows todays date if "D" is chosen or the 1st Jan if Q is chosen purely for illustration.
=IIF(Parameters!PeriodType.Value = "D", today(), CDATE("2022-01-01"))
I also set the advanced properties "Always Refresh" option.
i have a report which has extension of rdl (Microsoft Reporting Services Projects) in visual studio 2017 and this report has a date time parameter
i want to set a default value for this parameter as current date in order not to force a user to choose a value for this parameter
so when i right click the parameter i choose Default Values then Specify Values
then i add the Value =Now()
with no benefit when i preview the report the date time parameter becomes disabled
how to enter a default value as current date without time value
Your only question seems to be:
How to enter a default value as current date without time value?
To do this, rather than using =now() which returns the current date and time, you can use =today() which returns just today's date.
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.
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.
I am looking into a query from one of our users regarding the behaviour of date pickers on their report.
They have asked that when they enter a date in Date Paramater A that this is then duplicated in Date Parameter B.
I can achieve this when the report is first run by given Date Parameter A no default value (so it has to be chosen by the user) and seet Date Parameter B's default value via an expression to "=Parameters!StartDate.Value".
The question though is wether or not I can recreate this when Parameter A is updated. Therefore if they run the report once and then decide they need to choose another date. Can I set Date Parameter B to refresh each time Date Parameter A is changed?
E.G
Report is opened
Date Parameter A is set to 02/12/2013.
Date Parameter B now defaults to 02/12/2013.
Search is performed
A second search is required so, without closing the report the user changes the date in Date Parameter A
Date Parameter A is now set to 05/12/2013
Date Paramater B still says 02/12/2013 - can I somehow make this auto refresh to match Date Parameter A if Date Parameter A changes?
EDIT: Thanks to Kalim for pointing this out but it must also be noted that although I would like Date Parameter B to default to the new value selected by Date Parameter A, dates greater than that selected for Date Parameter A must also be available in case they wish to widen the range of dates.
Hopefully that is clear, but if any further information is required then please let me know.
Thanks in advance for your time and help.
You should be able to set the "Available Values" to the value of the first date parameter.
Select "Available Values" then select the "Specify values" option. Add a value and edit the expression of the value. Set this to the same expression you used in your default value expression.
Hope that makes sense!
Screenshot: