Working with parameters in SSRS 2008 - reporting-services

I have an (either or) situation in regards to parameters in SSRS 2008. I currently have my report working with a date range but I've been asked to add a drop down for the user to select the weekending date. I've got that drop down working but how can I switch between parameters (Date Range and the use of the Weekending Date drop down) for sending parameters to my report?

The way I allways fix this is by setting the parameters as nullable.
Then in my sql script I select all dates on the weekending date or between the daterange:
So whatever the user specifies, your sql script is filtered based on their parameters.
select *
from [table] t
where t.[date] = #WeekendingDate
or t.[date] is between #DateRangeFrom and #DateRangeTo

I usually handle this situation by creating an Internal Parameter(s) to sit between the UI and the query or stored procedure. The Internal Parameters are driven by expression depending on the user selection.
so lets say you want the user to either select a begin and end date range(Begin: 2012-01-01 End: 2012-01-31), or a month (Jan 2012).
If they select a value for Month. I convert that to an equivalent date range in the internal parameter expression. If they enter a date range I just pass through the begin and end values to the internal parameters.
Hopefully this makes sense. with a little work and imagination I think the approach can handle most scenarios.

One possibility would be to use the version control system of your choice to make another branch for the second report, change that one to use Week Ending, and then just make sure you merge changes every time you make a change to the main report.
I'm sure someone will come up with a cleaner way to handle it, though...

Related

SSRS report change date based on subscription

I'm trying to set two different dates for the same SSRS report.
What the report basically does is check a StartDate and EndDate these dates are default to yesterday.
But I have to implement a new subscription which has to look to the beginning of the month.
I've been investigating and I couldn't see any configuration rather than change the default date, but this will break the first subscription.
I'm thinking to add a boolean flag saying "check from the first" and an if inside the SQL query.
but I would like to know if there is any better approach rather than this "hardcoded" and ugly way, using the subscription if possible.
Thanks.
You can use a data-driven subscription to calculate the parameter values for the new subscription you want to create. Write a SQL query that gets the two date values you want to use. Then you can pass these in to override the defaults. You don't even have to edit the report and it will be dynamic.

SSRS - Cascading Parameter? Parameter value then shows two other parameters?

Apologies if this is rather straight forward. I'm very new to SRSS and looked across for a solution but unfortunately at a point where I don't know how to proceed.
My report has 1 parameter at present (Choice a Yes/No option - which is also set in the where clause of the dataset = Where Choice = #choice....
The issue I'm having is if Choice is Yes by user, I want it then to show two date parameters of Month and Year, then require user to select these and then view report. I've come across Cascading Parameters but correct me if I'm wrong this is related to the first parameter in this case Choice. However, the yes or no is a derivation from a case statement it has nothing to do with the date and they are not related from a database point of view. So not sure how I can get this to work. Do I need to add an expression?
I need two parameters showing when Choice = Yes
I then need to know how to add this to the dataset (if only yes has been selected).
Sorry once again this might be straight forward, but I'm been trying for a couple of days with no success.
Thanks in advance.
First of all, you cannot conditionally hide parameters, so all 3 will need to be visible from the start. However, you can control how they behave to get better functionality.
I would suggest adding a dataset to the report that provides a list of years. This dataset would be used to populate the Available Values for the Year parameter. You can have the query here check the Choice parameter and if it's set to "No", then the query simply returns "Not Applicable". So the dropdown for year just has that one option as is essentially disabled. Repeat the same steps for the Month parameter and dataset.
You will also need to make sure the main dataset will handle these values. So the WHERE clause might look something like this:
WHERE (Year = #Year and Month = #Month) or #Year = 'Not Applicable'

In SSRS How to limit start-end time within 7 days

I have a Report, I hope that if you choose to end time more than 7 days of the start time is prompt error.
Rather than give your users two date parameters have a single parameter to select the reporting period. You can use a SQL query to generate a list of weeks and then allow them to select which week they want to see data for. That way they can't ever select more than 7 days.
Otherwise you can short circuit the SQL by adding a DATEDIFF() between the two parameters. You could use an IF statement for this but you'll need to ensure that it returns the same columns and data types or I think SSRS will error out.
Otherwise just add the DATEDIFF() check in the WHERE clause so it will return no rows if the parameters are too far apart.
You'll also want to create a textbox on the report and have it conditionally visible if the parameters are too far apart. Something like big red text explaining to the user that they have selected a date range that is too large.
But, I think showing error messages should be avoided when you can just adjust the choices offered to the user so that they can't choose something that is invalid.

SSRS report with "Checkbox"-like feature that adds filters to query

I have a SQL database and using SSRS to produce reports. They are both 2012 version. The data is well water levels that are record every hour. Originally I have the report displaying ALL of the data for a user selected well (dropdown list). The user can also select the start and end date (text box) But the well levels don't change that much every hour unless there is a significant rain/flooding event. So I want the user to have the option to choose only the noontime values for each day. Is there a way to have a checkbox that would either 1) change actual query the report is using or 2) include filter that says only display 12:00:00? The parameter options seems to want to include a date and I only want to filter by time.
Thanks
I think the solution for you is to add a parameter to your report to be able to select what information to show with 2 possible values - All / Noon only. Then add a new field / calculated field to your dataset to indicate which ones are noon values. Then use the new parameter to filter the values showed in the report.
Hope it makes sense.

SSRS - Is there a way to restrict date/time input parameters to date only? (Not report output field format.)

I am writing an SSRS report that has several parameters including a couple of date fields. I do not want the user to be able to enter time information in either date field, but SSRS only has the Date/Time data type. Is there a way to force these report parameters to act as date only, and can I set a specific format (e.g., dd/mm/yyyy)? I would like to keep the built-in date-picker-calendar functionality.
I do not want to write my own report parameter web page because if I did then this one report would be the odd one out given that all of our other reports (which don't use date parameters) work fine with the built-in SSRS parameter entry functionality.
Perhaps the answer is that you can't do it with the built-in options, but that seems crazy - how could something so obvious have been overlooked?
The Google and Stackoverflow searches I've done only gave me ways to set the format in the report output (actually there are a number of cases where people have asked a question similar to mine and only received answers about setting the output format).
The problem is that you are using parameters that get timestamp information.
For example, if you are using Now() in your expressions- you will be asking for the current date AND the current time. However, if you use Today()- you will only be asking for the current date.
=Today() 'returns date only
=Now() 'returns date and current timestamp
Useful references:
http://msdn.microsoft.com/en-us/library/ms157328(v=sql.90).aspx
http://msdn.microsoft.com/en-us/library/ms157328.aspx
To answer my own question based on research I've done since asking it: it seems it is not possible to control how SSRS handles user entry of date/time values in parameters. If there is a need to restrict to date (or time) only or do cross-field validation then you need to implement your own front-end - which unfortunately for my specific business case doesn't help.
In my experience it has only given me the date and time when the filed you are selecting from contains both date and time. I have found if I am selecting on a date only field then I only get the date in the parameter
There is a way, but it will require you to CAST your date as Varchar(10) in your parameter dataset.
Next,You'll have to choose "Data Type:" as Text under Parameters section.
Again, you'll have to make sure your SQL code re-converts it into date again. I do not prefer this way, but users really wanted to see date without time.
Let me know if you'd like screenshot or more detail.