In my report, I have to include All Courses info(in the report) which is in parameter(selected value)
I am using this expression in checkbox:
="Course: " & Parameters!Course.Label
But this throws an #Error when I run the report. Any idea where am I going wrong.
Thanks,
Ar
Try this:
="Course: " & Join(Parameters!Year.Label, ",")
If your parameter is multivalue it is necessary to join the labels it returns, if you select multiple values the join() function will return comma separated values.
Related
In my SSRS report, I'm trying to display the City and State if the city exists and I'm doing so with this expression
=IIF(Fields!Ship_To_City.Value, Fields!Ship_To_City.Value & "," & Fields!Ship_To_State.Value, "")
the conditional part of it works, but whenever it's supposed to output the City, State, I get #Error. Any reason why?
An IIF conditional goes like this:
=IIF(boolean_condition, value_if_true, value_if_false)
Now, your IIF looks like this:
=IIF(Fields!Ship_To_City.Value, Fields!Ship_To_City.Value & "," & Fields!Ship_To_State.Value, "")
That is, Fields!Ship_To_City.Value is operating as a boolean value in the boolean_condition part but then as a string in the value_if_true part. One of these isn't going to work.
I assume you want to test that the field isn't null before outputing it, so you want to have an actual boolean condition in your IIF like this:
=IIF(Fields!Ship_To_City.Value <> Nothing, Fields!Ship_To_City.Value & "," & Fields!Ship_To_State.Value, "")
I have a dataset created from an expression that takes parameters from 3 other datasets.
I need to add a parameter to this that allows the user to input a value, and then the dataset will add that value to the where clause to filter the results displayed. If the value "Any" is input then the results will be unfiltered for this section of the Where clause (If that makes sense).
I wrote this and added it to the expression Where clause, but it is not working.
+ IIf(Parameters!RCode.Value = "ANY", "", " AND h.rcode = " + Parameters!RCode.Value + " ")
I can provide the rest of the where clause if it is needed, but if i remove this line, the whole thing works, if i add this line, it bombs out with
An error has occurred during report processing. (rsProcessingAborted)
Cannot set the command text for dataset 'DS'. (rsErrorSettingCommandText)
In the dataset query you can use parameter names by simple prefixing them with # eg. #RCode
To make it work, your WHERE clause should be look like (I assume your column name is rcode):
WHERE ....
AND (#RCode = 'ANY' OR rcode = #RCode )
For multivalue parameters
WHERE ...
AND ('ANY' IN (#RCode) OR rcode IN (#RCode) )
Helo. Today is my another fight day with OLAP raport with optional parameter. I have problem with MDX query. I wrote it like this:
select
NON EMPTY {{[Measures].[VALUE]}} ON COLUMNS,
NON EMPTY {
IIF(ISEMPTY([CUSTOMER].[${param}]) //CHECKING IF PARAMETER IS EMPTY
,{[CUSTOMER].[COUNTRY].Members},
{[CUSTOMER].[${param}]}
)
}ON ROWS
from [TRANSACTIONS]
${param} is my optional parameter for [CUSTOMER].[COUNTRY]. I unchecked "required" check button for my parameter, so OLAP should have all [VALUE] after executing it without parameter. And there is a problem, because after launching my OLAP raport parameter probably wants to be filled with something. It gives me an error.
Profile attribute 'param' not existing.
But I dont want to fill it with profile attribute. I have created list of values, and analytical driver for my parameter, which I use to pass possible values to my list box string parameter - ${param}.
Is there possibility to have OLAP report with optional parameter? Any BI master here?
I would be greatfull for any help.
Update: I have done something like this, I think this syntax is right, (I was checking SpagoBI examples)
WITH MEMBER [CUSTOMER].[SELECTED] AS ' Parameter("param") ' , SOLVE_ORDER = 2
MEMBER [CUSTOMER].[LEN] AS ' LEN(Parameter("param")) ', SOLVE_ORDER = 1
select
NON EMPTY {{[Measures].[VALUE]}} ON COLUMNS,
NON EMPTY {
IIF([CUSTOMER].[LEN]=0
,{[CUSTOMER].[COUNTRY].Members},
{[CUSTOMER].[CUSTOMER].[SELECTED]}
)
}ON ROWS
from [TRANSACTIONS]
But now I have same error for both possibilities (set/unset) parameter
javax.servlet.jsp.JspException: org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: com.tonbeller.jpivot.olap.model.OlapException: 1
Any ideas? Thanks :)
This question is a direct copy oF your previous posts:
https://stackoverflow.com/questions/38970610/olap-report-with-optional-parameter
Is ${param} is a string?
If it is a string then the following should function:
WITH MEMBER [Measures].[x] AS ${param}
SELECT
NON EMPTY {[Measures].[x]} ON COLUMNS
FROM [TRANSACTIONS];
Does it function?
If it does not function then the question is not really mdx related - as for some reason your syntax or the way the parameter is moving to the client is wrong.
note
The above is the equivalent of this super simple script:
WITH
MEMBER [Measures].[x] AS "hello world"
SELECT
NON EMPTY
{[Measures].[x]} ON 0
FROM [Adventure Works];
Do you have AdvWrks cube? Try these:
WITH
MEMBER [Measures].[x] AS "I'm not empty"
SELECT
{
IIF
(
(IsEmpty([Measures].[x])) //<< this returns False
,[Product].[Product Categories].[Category].MEMBERS
,{[Measures].[x]} //<< this is what IIF returns
)
} ON 0
FROM [Adventure Works];
It returns this:
Now I tested out IsEmpty:
WITH
MEMBER [Measures].[x] AS "I'm not empty"
SELECT
{
IIF
(
(NOT //<< added this to check functionality of IsEmpty
IsEmpty([Measures].[x]))
,[Product].[Product Categories].[Category].MEMBERS //<< this is what IIF returns
,{[Measures].[x]}
)
} ON 0
FROM [Adventure Works];
We get the following:
What I think is happening in your scenario is this - the param is not empty but is actually a zero length string:
WITH
MEMBER [Measures].[x] AS ""
SELECT
{
IIF
(
(
IsEmpty([Measures].[x]))
,[Product].[Product Categories].[Category].MEMBERS
,{[Measures].[x]} //<< the zero length string goes to here
)
} ON 0
FROM [Adventure Works];
Results in:
My situation is
I have a parameter, this is a list, allowing multi values. That mean the first record in the list is 'Select All'
When user select All I need to include in my report all records that match with the list plus those that are blank. (My dataset is returning these)
When user select only 1 or a few I want to include only these records. No those that are blank
My problem:
I have a filter in my dataset that evaluate a parameter in a list, but I need to add a conditional filter to include a blank records when the selection will be "Select All"
I tried to use expression but this doesn't work
Filter expression
Fields!NAME.Value in = Parameters!List.Value !!!!!!!!!!!! Work Fine
But I need to change it like as
If Parameters!List.Value = 'Select All' Then
Fields!NAME.Value in = Parameters!List.Value or Fields!NAME.Value = " "
Else
Fields!NAME.Value in = Parameters!List.Value
End
Can you give an advice who can I resolve it please !!!
I'm working in SSRS R2
Thanks!!
This worked for me
Expression: =IIF(Parameters!pLocation.Value <> " All Locations", Fields!LOCATION.Value, FALSE)
Operator: =
Value: =IIF(Parameters!pLocation.Value <> " All Locations", Parameters!pLocation.Value, FALSE)
If you use Filter on your Dataset, try this:
Expression: [NAME]
Operator: IN
Value (fx): =Split(Replace(Join(Parameters!List.Value, ","), "Select All", " "), ",")
Try to work along this path. Basically you can reconstruct the multi value items into a string with Join(), and deconstruct it again into array by using Split(); where in between, you can manipulate them, for modifying (e.g. converting "Select All" into " "), adding (imitating "OR"), or removing extra items.
There is an alternative for this.
Add one more item to the paramater dataset values say "Not Available" as Label and value with the null. then there will be no change in the stored procedure and you can retrieve the data.
If the user select the specific item then he will get those values only. If he selects all then he will get the data for the null also with the all the others.
Hope this will help
You can put the logic in just one location if you do it this way.
You filter on the parameter, unless it's all values then the filter always matches.
Just a little cleaner.
Expression: =IIF(Parameters!pLocation.Value <> " All Locations", Fields!LOCATION.Value, " All Locations")
Operator: =
Value: =Parameters!pLocation.Value
Can anyone tell me how to display all the selected value of my multi value parameter in SSRS report. When giving parameter.value option it gives error.
You can use the "Join" function to create a single string out of the array of labels, like this:
=Join(Parameters!Product.Label, ",")
=Join(Parameters!Product.Label, vbcrfl) for new line
I didn't know about the join function - Nice! I had written a function that I placed in the code section (report properties->code tab:
Public Function ShowParmValues(ByVal parm as Parameter) as string
Dim s as String
For i as integer = 0 to parm.Count-1
s &= CStr(parm.value(i)) & IIF( i < parm.Count-1, ", ","")
Next
Return s
End Function
Hopefully someone else finds this useful:
Using the Join is the best way to use a multi-value parameter. But what if you want to have an efficient 'Select All'? If there are 100s+ then the query will be very inefficient.
To solve this instead of using a SQL Query as is, change it to using an expression (click the Fx button top right) then build your query something like this (speech marks are necessary):
= "Select * from tProducts Where 1 = 1 "
IIF(Parameters!ProductID.Value(0)=-1,Nothing," And ProductID In (" & Join(Parameters!ProductID.Value,"','") & ")")
In your Parameter do the following:
SELECT -1 As ProductID, 'All' as ProductName Union All
Select
tProducts.ProductID,tProducts.ProductName
FROM
tProducts
By building the query as an expression means you can make the SQL Statement more efficient but also handle the difficulty SQL Server has with handling values in an 'In' statement.