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.
Related
I have 6 Datasets each one is the same query but has a different WHERE clause based on employee type. They generate 6 tables. At the top of the report there is a summary table which uses reportitems!textboxXX.value to grab the totals for 2 particular fields from all the tables. I'm also using a StartDate and EndDate parameter. Each reportitems! expression in the table comes from a different dataset in the report if that is relevant.
When I run the report using dates from yesterday back to the 9th of May I get the desired output.
But when I go to the 8th I get multiple rows all the same.
and as I go even further back I get even more rows of the same information. To my knowledge nothing interesting or different happened on the 8th of May and the tables further down the report look exactly the same. Any idea what might be causing this? The design view looks like this if that helps. There's no grouping or filters on the table.
Still not certain about the mechanics behind this but I found a 'solution' so I figured I'd post it. I just made a new dataset for my summary tables where the query was simply SELECT 1. Now I get a single row every time.
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'
I have searched looking for help but can't find exactly what I need.
I am trying to find the total number of days between two date fields, however the initiating date fields could be from two different fields, eg Start Date, or amended Start Date. The end date will always be the same field.
The majority of the time there will not be an amended start date but I need a way to cater for the scenario that an start date has been amended.
I tried the following
=IIF(Fields!AmendedStartDate.Value is nothing, DateDiff("d",Fields!StartDate.Value,Fields!EndDate.Value, DateDiff("d",Fields!AmendedStartDate.Value, Fields!EndDate.Value)))
I get an error run a run this.
I am fairly new to Report Builder/SSRS so I am unsure if what I am asking for is even possible.
Thanks for taking the time to look.
You can't do Fields!FieldName.Value is nothing, instead you need IsNothing(Fields!FieldName.Value):
=IIf(IsNothing(Fields!AmendedStartDate.Value),DateDiff("d",Fields!StartDate.Value,Fields!EndDate.Value),DateDiff("d",Fields!AmendedStartDate.Value,Fields!EndDate.Value))
Alternatively, you could create a Calculated Field (called say, StartDateToUse) with a similar expression:
=IIf(IsNothing(Fields!AmendedStartDate.Value),Fields!StartDate.Value,Fields!AmendedStartDate.Value)
And then refer to this field in your main expression to get the result you want:
=DateDiff("d",Fields!StartDateToUse.Value,Fields!EndDate.Value)
In the report I am building I have 2 data sets: one gives me, per user, per day, the total amount in that status; the other one gives me, per user, how many days in the date range the user actually showed up at work. Each of these data sets comes from its respective stored procedure. See screenshot.
The problem I have is that I need to report not the total time in status per user, but the average per day. So in the screenshot you can see that one user has 5 entries for 5 days worked and the other one has 3 entries for 4 days worked. simply because in one of those 4 days he didn't had that status at all.
I tried adding a calculated field to my "status" data set by using the lookup() function but it kept on giving me errors, which makes me think I don't quite know how to use it.
I also tried using group variables, and I was able to define it under group properties, but it never come up as an option to be used when writing an expression.
Any ideas using lookup(), variables or otherwise?
You're on the right track. Sounds like the Lookup function is exactly what you want.
Instead of trying to add the calculated field to the dataset, try putting it directly in the report item where you want this displayed.
Something along these lines should work:
=SUM(Fields!Available.Value)
/ Lookup(Fields!UserId.Value, Fields!UserId.Value, Fields!Days.Value , "NameOfDaysDataset")
If this isn't working, please post a few more details of your data sets, field names, and where you need this to appear.
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...