SSRS Report Parameter Issue - reporting-services

I have a report that contains 3 parameters. Start Date, End Date and Segment. The Segment parameter is a multi-value and is set-up as a default. When I run the report (after clicking view report) the Segment parameter value goes blank. When I select several values the report runs, but when I select all the parameter removes the default. I tried to troubleshoot the issue in Visual Studio 2013 and it runs fine, the issue is when it runs from the SSRS report server. Please advice. Thanks.

You can resolve the no data issue by doing the following:
assuming that your parameter names are :
#startdate, #enddate,#segment
Get a list of distinct segment values for your segment dataset.
For that you need to do something like the following
Assuming your table name is segmenttable and your column is segmentcolumn and there is a date somewhere that you join to do get all the distinct segment columns between the dates..
set your query for the segment parameter list to the following (something similar of course)
select distinct
segmentcolumn
from segmenttable
where segmenttable.segmentdate between #start_date and #enddate
This will always ensure that the segment parameter only has values between the dates that is selected and never any value that has "no data" associated with the segment..
Now set your available value and default value for your #segment parameter from this dataset. Done!

Related

Paginated Report-Date Parameter Range

I am using Paginated Reports against a dataset published in the cloud. I click on Query Designer to drag all the columns to the page and build my query parameters (i.e, not report parameters). When I add my date parameter, I have options in the dropdown of 'equal to', 'not equal to', 'contains', 'begins with.', 'range(inclusive)', 'ange(exclusive)', and 'Custom'. I want the date parameter such that when the user selects a date in the parameter prompt, the query returns 13 months of data, ending on the date they select in the parameter, so if they select 10/31/22, the results will be 10/31/21 thru 10/31/22. I don't want the user to have to enter a start and end date range if I don't have to. Given the parametr options I have, I don't see how to do this. I thought about modifying the code of the resulting query statement (it begins with EVALUATESUMMARIZECOLUMNS). I see logic in the code that says 'RCustomDaxFilter(#Date,EqualtoCondition'. I thought about changing the 'EqualtoCondition' to something like 'Between', but nothing works. Thanks for any assistance!

In SSRS, a Date Time parameter on Preview is not matching the deployed report

In SSRS, a Date Time parameter on Preview is not matching the deployed report. Is this something someone else has encountered? The RDL code is identical. Is it the fact that, sometimes, a local preview is just a simulation of functionality? Is it because the display in preview sometimes uses cached data?
I have a SSRS report that, when I preview it in Visual Studio locally, the date shows as 2/10/2019 but when the RDL code is deployed on the server, the date shows as 2/7/2019.
The date time variable is based on a parameter on the report, called rundate, and it has a Default Value of 2/10/2019.
So I think the same thing should happen on the Report Server that happens locally in preview mode.
The report has four datasets and, as a test, I have set each four to have the SQL line that sets the rundate value like so:
SET #rundate = '2019-02-10'
but on the report server, when I load the report, it throws this error:
Must declare the scalar variable "#rundate". Must declare the scalar variable "#rundate".
It is in a cascading tabbed error message that looks like this:
An error occurred during client rendering.
An error has occurred during report processing.
Query execution failed for dataset 'ThirdDataset.
Must declare the scalar variable "#rundate". Must declare the scalar variable "#rundate".
So, why does it run locally and not on the server? The "ThirdDataset" is a false name I have given here. The actual name is redacted. But, I have noticed that this would be the first dataset run if they are run alphabetically. So this leads me to the question: why doesn't the report recognize this as a parameter and why does it complain that it is not declared?
============
UPDATE:
I have set the rundate to be part of a data-driven subscription in a report like so:
SELECT convert (date, DATEADD (DAY, -2 , SYSDATETIME())) as rundate
Which is two days ago. Since it is 2/11/2019 today, the rundate parameter passed to the SSRS report on the server should be 2/9/2019.
For fun, to test this out, I set the Default Value rundate parameter to be 8/8/2018 in hopes that the data-driven report would set it properly.
In preview mode locally on Visual Studio, a textbox that set to show the [#rundate] Expression shows 8/8/2018 which is what I would expect, but the Datasets are designed to run off this parameter. Since there is nothing that the sql should retrieve from the database that is that old, the graphs and charts in preview mode should turn up completely empty. Why do they show data?!
Next, let's see what the emailed subscription alert says. It had the date of 2/11/2019 12:00:00 AM. If the data-driven subscription ran like it shouold ahve run, it should of had the date of 2/9/2019 from
SELECT convert (date, DATEADD (DAY, -2 , SYSDATETIME())) as rundate
Why did this not work?
On the SSRS server, the RDL file has a parameter default value of 2/11/2019 12:00:00 AM but why did the report get THIS default value? What am I doing wrong and how can I fix this?
As a test, I set this default date/time parameter to 12:12:34 for its time to see what would happen. It reveiled that, yes, this is the date time stamp that is being sent to the report. So I unchecked the "Has Default" box
Then, I noticed in the Step 5 of the data-driven subscription I could not advance to Next > without making a small change:
So, what should happen? Will it show the wacky 8/8/2018 value? Will it show the date from two days ago?
Default values for report parameters are deployed only once to the report server, and then they keep their default value after subsequent deployments. This is so that default parameter values used in development don't overwrite the desired parameter defaults on the production server.
So it looks like when the report was first deployed, #rundate had the default value 2/7/2019 but has since been changed on the local report to 2/10/2019. Go into your report server, find the report and go into the Report Parameters section to edit the parameters and change the default value to what you want it to be (deleting the report from the report server and re-deploying it with the updated parameter will have the same effect, but note that the parameter will maintain that default value going forwards). Alternatively, set the report parameter using an expression so that it is continually up to date.
Regarding updating your parameter value in the Sql statement using the SET statement, you can't actually do it that way - you need to set it in the report's parameter list so that SSRS can set the parameter value. Consequently, your databse server is complaining that you are trying to set the value of a local variable that hasn't been defined in your Sql statement, and thus throws an error message.
So you need to set up the Report Parameters in the report parameters section in the report designer. Your Sql can then reference your parameters like so:
SELECT * FROM MyTable WHERE SomeDate >= #rundate
The parameters normally get mapped into your dataset automatically but you might want to check this by going into the Parameters settings on your dataset to make sure. If the parameter doesn't exist there, set it up.
After lengthy trial and error, I found that the answer was to NOT have the parameter set to have a default value on the SSRS Report Server.

Calling a detail report using the intersection of Row and Column Sum as parameters

Description:
I have a report that that aggregates ATM transactions. This report has a Tablix with the following attributes:
Rows;
Vendor, Terminal.
Columns; Month, Day (Date), Hour.
The Row groups Terminal as child of Vendor and the Column groups Hour as child of Date and Date as child of Month. The Row Group and Column Group properties specify that each child visibility is toggled by its parent and the default if each child visibility to be hidden.
The Placeholder Value property for the intersection is set to Sum() transactions. The Action is set to Go To Report and specifies a detail report that accepts;
Start Date,
End Date,
Vendor,
Terminal
As parameters to the detail report. Each time the link is clicked, it calls the detail report with the dataset parameters set at runtime. So, for “North”, the detail report would reveal 41765 rows associated with the vendor “North”.
Problem:
No matter what resolution of detail in the matrix, when clicking the Sum() value to invoke the detail report, the dataset parameters set at runtime are sent to the detail report. For instance, if I drill down from Month to Date, I see that for Vendor “West” the sum of transactions on 2018-07-01 are 81. If I click that link to summon the detail report, it returns the total rows for the Start Date and End Date (1577 rows), rather than for the Date (81) as expected. This behavior is replicated throughout the intersection combinations.
Request:
How do I call up the detail report such that it returns only those rows specified at the resolution of the intersection in its current state? Ie: the sum at Month\Date: Vendor or the sum at Month: Vendor\Terminal or the sum at Month\Date\Hour: Vendor\Terminal….
What is the best method to accomplish the request? My research has not come up with any valid suggestions. I've attempted to use InScope() in the Placeholder Properties expression but can't seem to get it right.
Thanks for your help!
Your thought is correct, you have to use Inscope
Step 1:
For each parameter you use in your main report to call the subreport use an expression like
= Iif( Inscope("matrix1_Terminal"), Fields!Terminal.Value, Nothing)
For numeric parameters (like month number) set a dummy value like -1 because NULL values are not allowed
= Iif( Inscope("matrix1_Month"), Fields!Month.Value, -1)
Step2:
In the subreport change your parameters to accept NULL values (only for strings and dates)
Step3:
On the subreport adjust your query code to handle dummy parameter values
For string or dates
WHERE (terminal = #Terminal or #Terminal IS NULL)
For numeric values
WHERE (month = #Month or #Month=-1)
Important!!
Don't forget to pass to the subreport other parameters needed like filters in the WHERE of the original report
Tip: In the subreport use temporary string parameters for debugging and pass the values of your Inscope expressions

Fields cannot be used in report parameter expression

I have to set the start_date of my report depending of a report parameter. The time stamps are calculated in a database query.
My expression looks like this:
=SWITCH (
Parameters!report_type.Value = 1,First(Fields!daily_start.Value, "Timestamps")
,Parameters!report_type.Value = 2,First(Fields!weekly_start.Value, "Timestamps")
,Parameters!report_type.Value = 3,First(Fields!monthly_start.Value, "Timestamps")
)
Unfortunately I get the error message:
A value expression used for the report parameter 'time_from' refers to a field. Fields cannot be used in report parameter expression
I know, that this is not allowed because SSRS cannot be sure in which order datasets are called. But I think this is not dangerous.
All time stamps are received by query without parameter. The parameter report_type is selected by a user before the report will be generated.
Can someone give me a hint for a workaround?
Here's the workaround - get the value using SQL.
Create a new Dataset called StartDates:
SELECT CASE
WHEN #report_type = 1 THEN daily_start
WHEN #report_type = 2 THEN weekly_start
WHEN #report_type = 3 THEN monthly_start
END AS StartDate
FROM MyTable
You already have the #report_type and #time_from parameters. With the #time_from parameter, set its Default Values to Get values from a query using the StartDates dataset and the Value field StartDate.
Now, you'd think this might be enough to make it work - you're referencing this query as the default value and as you change the #report_type parameter the other parameters refresh, but the first date in the #time_from parameter never changes. That's because the refresh happens on the Available Values query, not on the Default Values query.
So you also need to wire up the Available Values query to the StartDates query. Now your query will fire on the change of #report_type and the default value will be set to the appropriate date for your selection.
I switched from a query to Stored Procedure and was getting this error. Things I tried:
Ensured I had sufficient permission on the database (you need EXEC rights or DBO to run teh sproc)
Delete the existing parameters (and then use refresh fields to refresh/get the correctly named ones back)
Remove the square brackets around the stored procedure if you've specified that
Sometimes, Expressions can get a bit verbose. I have created a Report Code Function and then used that as the Parameter Value.
For example, I created a Code function called "CalculateDateSet" and then set the Report Parameter to this expression:
"=Code.CalculateDateSet(Parameters!Month.Value, Parameters!Year.Value"

Parameter missing a value

I am new to reporting services and have a reporting services 2005 report that I am working on to use as a base report template for our organization. I am trying to place the date that the report was last modified on the report server into the page header of the report. However, I keep getting a 'ParamX' parameter is missing a value error when I try to This is what I have done:
Set up a Parameter ReportName with a default value of Globals!ReportName. It is also hidden and internal.
Set up a Dataset ReportHeader that calls a stored procedure that returns the date the report was last updated or another date, if the report is not on the report server. It has a parameter #ReportName assigned to the Parameter!ReportName.Value. The Dataset returns values when run on the dataset tab in the BI tool.
Set up a Parameter ReportVersion that has a default value Query From based on the dataset ReportHeader and picking the ModDate column. It is the last parameter in the report parameters list.
I assign a textbox to the parameter.
When I preview, I get "The 'ReportVersion' parameter is missing a value whether I place it in the report body or page header (which is where I want it). I have deleted and added the parameter again, toyed with the hidden and internal settings on it.
What does this error really mean, what I am missing, and can I even do this with parameters?
Thanks In Advance
Jim
If I understand what you're doing, it sounds like you want to be using a field where you're implementing a parameter...
You are returning the ModDate from the data source, correct? If you're doing this, you can simply throw a text box in there, and use something like this: =Fields!modDate.Value to display it.
Parameters are values that go in to the query, fields are what it returns.
Hope this helps...
EDIT:: OK so are you trying to retrieve the mod-date column value from the reportserver db? If that's what we're talking about, you'll need to add a few things to the report. Add a datasource to report db, a dataset containing the date (query below), a list object in the report linked to the dataset, and a textbox in said list object to display the field. If you hit the report server with a query like this:
SELECT MAX(ModifiedDate) AS ModDate FROM catalog WHERE name='myReportName'
That will return your modifieddate from the ReportSErvices Database as a field that you can use.