Set Default parameter in SSRS from a dataset - reporting-services

How can i set the default parameter in SSRS using a value from Dataset?
I want the default parameter to be the previous month date that is selected from a table tblPeriod(per_id, lastDay)
tblPeriod stores the months in a set of 20 year with last day storing the last day in a month.
e.g
2000, 31-Dec-2016
1999, 30-Nov-2016
I wrote this SP getPeriod which works like this-
select per_id, lastDay , (select per_id from tblPeriod where lastDay < getDate()) as maxDate from tblPeriod
The report populates a drop down with all period values
How to make the default date as previous month end date using the maxDate value returned by the Stored Procedure?
<ReportParameter Name="period">
<DataType>Integer</DataType>
<Prompt>Period</Prompt>
<ValidValues>
<DataSetReference>
<DataSetName>Periods</DataSetName>
<ValueField>per_id</ValueField>
<LabelField>lastDay</LabelField>
</DataSetReference>
</ValidValues>
</ReportParameter>
I would also like to know how to set the top most item in a parameter drop down as the default selected item in the report

Click on default value option then click on function then you can write a function to get the date you are wanting like [#parameterName] will get the entered parameter then use some of the math function to modify it like you need. Your problem is hard to solve without seeing what you are doing in the GUI and you will have to get pretty creative to solve it.
Sorry I can't be of more help. If you add some screen shots I may be able to help more.

Related

Start Date Range parameters in SSRS

When I set up my SSRS report originally I set it up to look at the current day so my where clause in my query was:
Where
trunc(START_DAY) >= current_date -1 And
trunc(START_DAY) <= current_date
Now I want to add parameters to select just the "START_DAY."
How would I go about setting this up?
It sounds like you're using Oracle where the TRUNC function is converting your datetime to a date.
In this case you would set up a date parameter in SSRS. You can add a default date of today or yesterday.
Then, in the SSRS dataset, add the parameter to your Oracle query.
Where TRUNC(START_DAY) = :DATE_PARAM
You may need to map the parameter manually in the Parameters tab of the dataset.

SSRS select parameter month and change par. first and last day of this month

i need to create parameter list of months and then (after select) recalculate two others paramateres in date format ([first day] and [last day]) of this month, can you please help me?
You are querying a database server to generate the list of months, although there's no need to do that. I suggest to rather create a list of months in the report and let the report calculate the month's names, so the language depends on the Language setting of the report (which can be the language configured in the user's browser).
For example, to calculate the Label for the Value 1, use an expression like =MonthName(1).
The Parameters FirstDay and LastDay (or just the values whenever you need them) can be calculated using these expressions:
FirstDay: =DateSerial(Today.Year, Parameters!Month.Value, 1)
LastDay: =DateSerial(Today.Year, Parameters!Month.Value, 1).AddMonths(1).AddDays(-1)

SSRS Dynamic Date Parameters

I'm fairly new to reporting and need help with the following?
I have a report that has two date parameters statically set to default to the last financial year. i.e. the FROM parameter 01/04/2015 and the TO parameter 31/03/2016.
When the actual date next year is 01/04/2017 I need these parameters to change forward by one year, I know I maybe able to do it with a case statement and a getdate + dateadd .
I have a small table which creates a year period based on certain dates which I then join onto the data then I use that to filter.
for instance:
1516
1617
1718
so if #year_period = 1516 then the previous year would simply be #year_period-101 and the future would be #year_period+101

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()))

Report Builder - Set datetime parameter

I have a report that has parameters StartDate and EndDate. I would like the EndDate parameter's time part to default to the end of the day when selected from the drop down.
For instance, if a user selects 5/15/2008 from the dropdown, the value shown in the box should be '5/15/2008 23:59:59' not '5/15/2008 12:00:00'
Its pretty easy to do this in .Net using the event model and a line of code but in Report Builder 2.0, what would I need to do?
Is there code that I need to write for this or did I miss some funky expression that could handle this?
Thanks.
AboutDev
I would suggest setting the default parameter in the Report Parameters section. You can get to this from Report > Report Parameters.
This allows you to set a non-queried default. There you can enter an expression like
=DateAdd(Microsoft.VisualBasic.DateInterval.Second ,-1,dateadd("d",1,Today))
That should give you a default for the end of today.
Edit: Really only useful for a single default value.
It's been awhile since I've used SSRS, so bear with me. You'll have to do a little translation, but here's what I've done in the past.
When you define your EndDate parameter, create an additional parameter named EndDateEOD, after EndDate in your list of parameters. Make this parameter a hidden value, and set it to the last moment of the day, similar to the way that Jeremy calculates it.
Then you can use #EndDateEOD in your report query where you have #EndDate now.
When StartDate is selected, you could have EndDate default to its value, so that EndDateEOD will automatically be set to the end of the start date.
Use the parameter in a DATEADD() expression in your dataset.
Rather than
...WHERE end_date = #end_date
do something like this:
...WHERE end_date = DATEADD(ms, -3, #end_date + 1)
That will go forward a day (the +1), then go back 3 milliseconds, to the last instant of the day recordable by a datetime.
You can do something like this:
=CDate(Parameters!StartDate.Value + " 23:59:59")
The part of Parameters!StartDate.Value can be any date but not the EndDate.Value itself. Eg:
- Today()
- Last day of the month from start date:
=CDate(DateSerial(Year(Parameters!StartDate.Value), Month(Parameters!StartDate.Value) + 1, 0)+" 23:59:59")
Hope this help.