Paramter is missing a value in SSRS - reporting-services

I'm calling a Detail report from the summary report and my summary report field is passed as a parameter to the detail report. However when clicking on certain rows based on one condition, the detail report opens correctly.
Certain rows shows the type parameter is missing.
I am passing the type value while invoking the reports and value is passed from the type field in the summary report
Eg IF(#type=''A'')
EXEC AcceptedDetail
If (#type = ''R'')
EXEC AcceptedDetail
In this case R works fine while A does not.

Try
DECLARE #type CHAR(1) = 'R'
IF #type IN ('A','R')
BEGIN
EXEC AcceptedDetail
END

Related

SSRS Report Parameter Issue

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!

Cascading parameters in SSRS reports doesn't work with one parameter value set to a default value

I'm trying to run an SSRS report with cascading parameters.
I have 2 parameters para1, para2.
I have made para1 as a hidden field and assigned para1 a default value.
I have set para2 to take available values from a dataset.
I'm trying to populate para2 drop-down based on para1's default value.
My query for populating para2 is
SELECT column2 FROM TABLENAME
WHERE (column1 = #para1)
(here column1, column2 from Database refer to respective para1, para2 parameters in report)
I have my query working fine with the database and I see filtered result but gives me an error when I click preview on BIDS.
Error:
The report parameter ‘para2’ has a DefaultValue or a ValidValue that depends on the report parameter “para1”. Forward dependencies are not valid.
I'm unable to figure out where I'm going wrong. Please help me find my mistake. Thank you.
Change the order of your parameters in the parameter list.
On the menu bar click View>Report Data
Then highlight one of the parameters and click the up or down arrow (depending on the highlighted param)
The up and down arrows are located at the top of the Report Data list. You should end up with Para1 being above Para2 in the parameters list.

Blank Parameter to Null Parameter in SSRS

I have a drilldown report whose parameters are: parent report - #valid Nvarchar(20) = '' and in child report - #valid Nvarchar(20) = Null.
Both reports run very well but I have an issue after mapping up this parameters in the Text Box Properties > Action > Go to Report. When the report is run I get the error,
"the value provided for the report parameter is not valid"
The query for this report is from a stored Procedure. In the child report, Parameter Properties, I have ticked the "allow Null values" text box, Set available parameter to come from a query and specify a default value to come from a query. What have I done wrong to allow for the error returned? Your help is appreciated.
Thank you.
If you're second report is expecting a NULL values, (i.e. Nothing in SSRS), you can pass an expression-based parameter to the child report based on the parent parameter, making sure that if it's an empty string at the parent level, you can explicitly set this to Nothing:
=IIf(Parameters!valid.Value = "", Nothing, Parameters!valid.Value)
This way the empty string will never get passed and your child report; only the NULL value it expects.
if you're considering passing a null parameter from URL, let's say some sort of CLI, you must include a parameter:isNull=True in the parameter section of the URL. and allways remenber to check the "allow null value" in report editor, parameter properties.
let's say we have a report, of sports and stadiums, and we have a null sport... it would be something like this>
http://<server/report>&rs:Command=Render&rc:Parameters=false&rc:toolbar=false&sport:isNull=True&stadium=CampNou
Set the Parameter to Allow Blank = Yes and the Default Value = "". In the code make allowances for the blank parameter.

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"

Setting Parameters from another Parameter In SSRS

I was able to get this working is SSRS 2008, but do to the fact that my company only has 2005 servers I need to downgrade the report to 2005.
The idea is for a given person name there are two key fields EntityType and EntityId
So I have a parameter from a dataset where the Label is the Name and the value is EntityType_EntityId
I use the split function to take the left and right sides of from _
In 2008, I set the query parameters of the dataset to the split function and it works
In 2005, I set the Default Value of each Report Parameters
Now when I run the report and put textboxes showing the value of the parameters, the values are shown correctly but the query does not run. I am guessing that this is a lifecycle issue being
Get Name Parameter
Run Report
THEN Set Parameters = Split of Name
But the problem with that is the second time I run the report I should get result and I do not. Does anyone know what I am doing wrong.
I guess I can pass in the underscore delimted string to the stored procedure and parse it there, but my question is can this be done in the report? Reason being other callers will pass in the parameters as two seperate values.
I already found a suitable answer
Set the query source as text
DECLARE #EntityType INT
DECLARE #EntityId INT
IF #Name = '0_0'
BEGIN
SET #EntityType = NULL
SET #EntityId = NULL
END
ELSE
BEGIN
SET #EntityType = LEFT(#Name,CHARINDEX('_',#Name)-1)
SET #EntityId = RIGHT(#Name,LEN(#Name) - CHARINDEX('_',#Name))
END
EXEC proc #EntityType, #EntityId