I am creating a SSRS report where I require to call different queries based on some condition. mainly with Globals!RenderFormat.IsInteractive.
If Globals!RenderFormat.IsInteractive is true call 1st query block otherwise other query block.
In query itself it is not possible to create IF condition using Globals!RenderFormat.IsInteractive. so I tried creating report variable and parameter with default value of Globals!RenderFormat.IsInteractive but both giving error of query refers to the global variable RenderFormat, which is not valid for this type of report item expression.
Is there any workaround for it?
Related
I am using Visual Studios 2015 with SSDT installed. I cannot show my query as it has confidential columns in it. Let's just say I have two temporary tables that gather general data which are joined in the select statement and uses a where clause that accepts a multi-value parameter of text datatype (column is char(8)) to filter the information in the report. I have checked allow multiple values in the parameter properties. There are no available values, the user types the values in. (I've also tried supplying values in drop down list with same results).
Where smpl_lvl_cd in (#SampleLevel)
I would think this is quite simple and when the user selects one value, everything works well. As soon as you choose more than one value, you get the error "An expression of non-Boolean type specified in a context where a condition is expected, near ','."
For example: Sample Levels 'Q' and 'V' are selected. The way I understand it, SSRS send 'Q,V' to the query. (Or does it send "Q,V,'?) With this in mind, I've tried using:
Where smpl_lvl_cd in (select value from string_split(#SampeLevel, ','))
with similar results "Procedure or function string_split has too many arguments specified....." followed by the same Boolean message.
This parameter is not being sent to a stored procedure but I've tried using the join function on the parameter in combination with the string_split in the query. I end up getting no data for more than one selection.
Please help.
See this article: SSRS multi-value parameter using a stored procedure. You have to change your multi-valued parameter array into a string before sending into your dataset. therefore send the expression =Join(SampeLevel!Value,",") instead of [#SampeLevel]
I'm using report viewer and trying to create dynamic groupings on my table. Before the report is generated, I have a popup that ask if the report generated should be grouped by category or not.
I have two datasets, one called ReportParameterDTO and the second is called LoanDTO
The tablix is connected to the dataset LoanDTO. I want to create a parent grouping expression for that tablix such that if the first value of ReportParameterDTO.GroupByCategory is true, then it should group, otherwise do nothing.
What I tried
=IIF(First(Fields!GroupByCategory.Value, "ReportParameterDTO") = true, Fields!Category.Value, ""))
It gives me back and error around Fields!GroupByCategory.Value and the error within the error list states that A group expression for tablix includes an aggregate function.
The IIF Expression will compile if I use Field Values from LoanDTO but I don't want to do that.
Add a new parameter.
Set it to Internal.
Set the Available Values to pull from the ReportParameterDTO dataset and the Value field will be GroupByCategory.
Also set the Default Values to pull from the ReportParameterDTO query.
Now you can refer to this internal parameter in your grouping expression like so:
=IIf(Parameters!GroupByCategory.Value = True, Fields!Category.Value, Nothing)
You can create both table and whit your parameter show or hide the table visibility. So like this I think is going to be more easy for you to set up your table and groups.
I am using SSRS 2008 R2. My RDL has several subreports in it which all take one field value only from this parent RDL as their inputs. This one field value is called "people_id". There are some instances though where there are 0 records returned from the parent RDL. When this happens, I get the following error when I run this report from the parent RDL:
An error occurred during local report processing. Object reference not set to an instance of an object.
Even though I tried setting the paremeter value for my subreports to both:
people_id
and
=iif(isnothing(Fields!people_id.Value),"",Fields!people_id.Value)
How can I successfully avoid this error when there are no records?
I guess it's too late but in case of helping anyone else.
Some values in an expression can evaluate to null or undefined at report processing time. This can create run-time errors that result in #Error displaying in the text box instead of the evaluated expression. The IIF function is particularly sensitive to this behavior because, unlike an If-Then-Else statement, each part of the IIF statement is evaluated (including function calls) before being passed to the routine that tests for true or false. The statement =IIF(Fields!Sales.Value is NOTHING, 0, Fields!Sales.Value) generates #Error in the rendered report if Fields!Sales.Value is NOTHING.
From http://msdn.microsoft.com/en-us/library/ms157328.aspx
I had a similar issue and ened up with writing a custom function.
Instead of =iif(isnothing(Fields!people_id.Value),"",Fields!people_id.Value), can you try =iif(isnothing(Fields!people_id.Value),NOTHING,Fields!people_id.Value)?
The following picture shows the query and its result with no variables:
The next one shows the same query with a variable and a different result:
This how the parameter was set just before the query execution:
I have also tried setting the parameter without '' but it produces the same result.
Any clue about what's going on? Any help would be greatly appreciated.
NOTE: The DBMS is MySql
This weird issue is due to the fact that SSRS is connected to MySQL by ODBC connector; therefore, the query parameters should be defined as ? and their names are Parameter1, Parameter2, etc... in order of appearance
Source: http://www.tek-tips.com/viewthread.cfm?qid=1354185
In Report Builder 3.0 you can user parameters in a dataset query using the following syntax:
WHERE sql_column_name = (#Parameter_name_in_ReportBuilder)
Example:
SELECT * from [dbName].[dbo].[TableName]
WHERE Account=(#Parameter1)
Before you can run the report, you need to configure a paramter named Parameter1 (in this example, change this to the name of your parameter) in Dataset Properties - Parameters. The value field should be set to one of the parameters
Parser: The query contains the XXXXXName parameter, which is not declared. (msmgdsrv)
I have no idea why I keep getting this error. It occurs when I change the MDX in the query designer and trying OKing out of the query designer.
The strange thing is that the parameter DOES exist, I can see it in the parameters section of the dataset dialog. I am creating it before I do anything else with the query.
Although the seemingly intuitive thing to do is add the Parameter in the Dataset Properties window, this actually does not declare the parameter for the query for some odd reason.
To add the parameter, click the Parameters toolbar button in the Query Designer window. From there you can add your parameter names and default values.
Once you've done this, the global parameter list will contain that parameter and allow you to use expressions etc..
Is the parameter defined at the report level? That might be what's missing.