Correct Syntax for optional multi-select parameter in BIP - obiee

I have a query that was written as a Data Analysis in Oracle OTBI, and I am using it inside of BIP Data Model and I am structuring parameters for the Oracle BI EE logical SQL. The below parameter :P_Item_Number I would like to use as an optional multi-select parameter in the WHERE clause, where the user can either select 1 or more Item numbers, or they can leave it set to All so that it doesnt filter items.
AND ("Main"."Item" IN(IFNULL(:P_Item_Number, null)) or :P_Item_Number IS NULL)
I am getting the following error when trying to validate the statement:
java.io.IOException: prepare query failed[nQSError: 43113] Message returned from OBIS. [nQSError: 43119]
Query Failed: [nQSError: 46033] Datatype: 25 is not supported.
The :P_Item_Number parameter is a string parameter setup for Multiple selection:
What do I need to update my syntax to for this to work? Thanks in advance.

In your Where clause put something like:
... ... ...
WHERE ITEM IN(:P_ITEM_NUMBER)
... ... ...
AND
when defining the parameter (P_ITEM_NUMBER:Type:Menu) select the option "All values passed" this means all selected values (could be 1, more then 1 or All)
ADDITION
Here are the test screens as a sample. If you define it all right then if checked left of All - you get all the params listed, if it is not checked but there is 1 or more of the options checked you will get them and if nothing is checked then nothing is going to be selected...

Related

Limit the number of Multivalue parameter selections SSRS

I have a report with a parameter with about 12 multivalue parameters. Is there a way to select 5 parameters and when selecting the 6th parameter displaying 5 is the limit ??
Any ideas are appreciated.
As a work around , you could try using a combination of a visibility expression to count the parameters chosen and a separate text box with a warning message, such as :
=IIF(Count(Parameters!XYZ.Value(0),"DataSet1") > 5 , "too many parameters selected", "ok")
and using a variation of the expression to hide / show your original report.
There is no way to give immediate feedback when the limit is exceeded. One option would be to show a message once they click the View Report button. It's a bit of a workaround, but you would have to have the dataset return no rows. Then for the message, you could either have a texbox with conditional visibility somewhere on the report OR you could use the NoRowsMessage property on a table to show the appropriate message.
If you have a more complex situation such as multiple parameters, you can just add in more conditional logic to the dataset and message to check if all the conditions are met and which message should appear.

Hidden Parameter is missing a value

In my report, i have created a xxx parameter which takes values from the report data set.
xxx parameter is not being passed to stored proc which is used to show the data for the report.
Now When the report does not have any data for other parameters, i get an error saying xxx parameter is missing a value.
I tried allowing blank values in the parameter properties.
Check that parameter's - Available Values by going to report parameters properties.
It must not be specified any values. So we should set it as None
Another way is,
Just add a blank space at Specify values - in Default values inside report parameters properties.
Third way
Ido an "if exists" statement for this to go away. It worked for me because it makes it always return a value even if that value is not need by my query.
if exists (my select query)
my select query
else
select '2'
// '2' would never be used, but it made ssrs stop giving me
// the stupid error and execute
This should help.

Use SSRS Expression to Hide Tablix Based on Parameter Selection

I have a report that displays sales by county or by agent - but the user cannot select both. The #AgentOrCounty parameter is hard-coded: Agent = 0 and County = 1. And the #AgentID parameter only accepts one value but the #CountyID accepts multiple values. And my report has two tablixes: one for the dataset and one to display an error message if the user selects both an #AgentID and #CountyID
What I hope someone can help me with is how I can write two expressions to hide the tablixes based on the user selection.
One additional issue I am experiencing is that the #CountyID parameter is a multi-value parameter that I have to pass a NULL value to to allow the report to run if the user wishes to display by Agent.
Right now, on my Error Message tablix, I have the following expression:
=IIF(LEN(Parameters!AgentOrCounty.Value)=0,TRUE,FALSE) OR IIF(LEN(Parameters!AgentID.Value)=0,TRUE,FALSE)
But this doesn't hide the Error Message tablix when the user runs the report correctly for Agents.
When I think in logical terms, I would like the Error Message table to be hidden if the #AgentOrCountyID = 0 and #CountyID is NULL or the #AgentOrCountyID = 1 and #AgentID is NULL.
And I would like the report data tablix to be hidden if #CountyID and #AgentID are both not NULL.
Any suggestions?
To hide the error message tablix, I used the following expression:
=IIF((Parameters!AgentOrCounty.Value=0 And Parameters!CountyID.Value(0)="NULL")
Or (Parameters!AgentOrCounty.Value=1 And Parameters!AgentID.Value Is Nothing),True,False)
And to hide my data set tablix when the user selected both an agent and a county, I used the following expression:
=IIF(Len(Parameters!AgentID.Value)>0 And Len(Parameters!CountyID.Value(0))>0,True,False)

IIF Statement in TablixFilter issue

I'm trying to filter a matrix in my report. I have names of 4 drivers and I want the Matrix5 to show the name of a default driver in case SELECT ALL is checked in filter. Otherwise I want the matrix to show whoever is checked.
I set an expression at matrix filter as;
=IIF(Parameters!Sofor.Count=4,"abcdef",Parameters!Sofor.Value)
-abcdef is the name of the default driver for the tablix
-Sofor is the driver name parameter and has 4 total possible name options, 5 if we consider SELECT ALL too.
It works well if I check SELECT ALL but stops working if I select only one option.
Error I'm getting is as follow;
"The processing of FilterExpression for the tablix "Tablix5" cannot be performed. Cannot compare data of types System.String and System.Object[]. Please check the data type returned by the FilterExpression"
Though the error sounds pretty self explanatory I still can't understand what I'm doing wrong. Any help please?
Parameters!Sofor.Value is an array of values (the object) because its a multi-select parameter. (what happens when the user chooses 2 drivers?)
Try
=IIF(Parameters!Sofor.Count=4,"abcdef",Parameters!Sofor.Value(0))

BIRT Before Open value list params errors

I have a (semi) basic data cube set up with a cascading parameters of State and Area. The state select box is straight forward as is the Area; when a user selects a State, the Area options are set accordingly. However, the value for Area is a long list of strings that will be sent to the mysql select statement which will use both params (State & the list of strings from Area) several time. Its a big ugly collection of UNIONS. My problem is somewhere between the before Start and query time.
//beforeOpen script...LState & LAreas the name of the report param
this.queryText = this.queryText.replace('stateList', params["LStates"].value);
this.queryText = this.queryText.replace('areaList', params["LAreas"].value);
In my mysql statement I use them in the following way:
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ('stateList')
AND Range_Locator.Range in ('areaList')
UNION ALL
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ('stateList')
AND Range_Locator.Range in ('areaList')
The two errors I get from BIRT are:
(Pretty obvious)
Cannot get the result set. org.eclipse....SQL statement doesn ot return a ResultSet object.
(Not so obvious to me)
A BIRT exception occured. Error evaluating Javascript expression. Script engine error: Can't find method java.lang.String.replace(string.java.lang.Object[]).
There are error evaluating script "this.queryText = this.queryText.replace('stateList', params["LStates"].value);this.queryText = this.queryText.replace('areaList', params["LAreas"].value);"
Any ideas? Any help would be greatly appreciated.
It seems LStates is defined as a "multi-value" parameter, therefore params["LStates"].value returns an array of values: this is why this replace method does not work.
You should try like this:
this.queryText = this.queryText.replace('stateList', params["LStates"].value.join("','"));
I am not exactly sure what you are doing in beforeOpen script, but your SQL is looking for the string values 'stateList' & 'areaList' and is probably not happy about the (). You need to use question marks to call the parameters you define in the 'parameters' you set up in the data set design.
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ?
AND Range_Locator.Range in ?
UNION ALL
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ?
AND Range_Locator.Range in ?
I don't recall using
in ?
In any queries, I usually try and set it to use
like ?
There are number of issues in sending multiple choice parameters to SQL via BIRT. you might want to look at How do I set a parameter to a list of values in a BIRT report? There are also some security concerns. When I have to filter on multiples, I usually do it in a filter (data set design option) after the SQL has run. Thought this can be a resource problem if your SQL returns lots of values.
Thanks for the replies but since I was unable to get these options to work, I wound up restructuring the database & sql statements to run better. To address some previous suggestions:
#dom the states parameter has only one value and while using "IN ('stateList')" is not efficient (disclaimer, not my code) adding the .join(',') did throw an error specific to that; I tried and mysql/BIRT seemed to be expecting a comma separated list but got a string with a trailing comma.
#James I tried using the question mark (?) instead of the 'stateList' & 'areaList' but I think mysql/BIRT was not able to recognize which value went with which question mark...not too sure though since I was not able to debug well enough and find out exactly why. Could be a form to param mapping issue that I didn't notice. Thanks for the help.

Resources