I am facing some issues with parameter in SSRS reports that when my Multi value parameter contains the space in between then I get the syntax error
If i choose any other parameter value which do not contains the space then it works well. I am using SSAS cube as a data source
WITH MEMBER [Measures].[PV] AS #Percentile
Member [Measures].[CntCT] as Count(NonEmpty(STRTOSET(#State) * [Tb Main].[UID].[UID].ALLMEMBERS,[Measures].[CPT1] ))
Member [Measures].[PVInt20] as Int(((([Measures].[CntCT] - 1)* [Measures].[PV])/100) - 1)
Member [Measures].[PVC] as
([Measures].[CPT1],Order(NonEmpty(STRTOSET(#State)*[Tb Main].[UID].[UID].ALLMEMBERS ,
[Measures].[CPT1]), [Measures].[CPT1],BASC).Item([Measures].[PVInt20]))
Select [Measures].[PVC] on columns, STRTOSET(#State) on rows from [POC 1];
Query works in query designer with both parameter and entire unique name i.e [Tb Main].[State Name].&[Wash DC]
Try changing the state parameter query to:
WITH
MEMBER [Measures].[ParamValue] as [Tb Main].[State Name].CurrentMember.UniqueName
SELECT { [Measures].[ParamValue] } ON COLUMNS,
NonEmpty ([Tb Main].[State Name].[State Name].ALLMEMBERS, [Measures].[CPT1] ) DIMENSION PROPERTIES MEMBER_CAPTION ON ROWS FROM [POC 1]
Use the ParamValue column as the value property of the state parameter. Then your query downstream should work even when there are spaces.
Related
ssrs filter tablix expression that will use parameter value to filter tablix
Id like to filter my tablix based on one parameter with 3 possible values to select from.
Person
Dog
Both
Then filter the tablix by field: Person, Dog, Both...
---update
Tablix Filter by parameter values. Goal include ALL
1 Parameter has 3 options (not multi select). PERSON, DOG, ALL.
I have a field built called FILTER that places "ALL" in the cells.
Otherwise its between the field CLIENT_TYPE "PERSON" or "DOG"
expression:
Fields!CLIENT_TYPE.Value
Value
Parameters!CLIENT_TYPE.Value
This works for "PERSON" and "DOG" only. Dopes Not work for "ALL"
What would be the Expression and Value to filter the tablix according to parameter...
could I trick the "ALL' into excluding nothing?
expression
IFF(Parameters!CLIENT_TYPE.Value = Fields!CLIENT_TYPE.Value or Parameters!CLIENT_TYPE.Value = Fields!FILTER.Value
, "include"
, "Exclude")
Value
=Parameters!CLIENT_TYPE.Value
RESOLUTION:
expression
=(Fields!CLIENT_TYPE.Value = Parameters!CLIENT_TYPE.Value)
OR
(Parameters!CLIENT_TYPE.Value = Fields!FILTER.Value)
value
=true
you will click on your tablix properties -> visibility and then pop and expression like so
iif(parameters_p1.value = 'Person',True,False). Keep in mind that if you have a select all option i.e. param can accept multiple values This solution WILL NOT WORK. It will only accept 1 value at a time and render result for that.
You'll want to compare your field with the parameter.
For a filter expression, you'd have something like
=IIF(Fields!YOUR_FIELD.Value = Parameters!YOUR_PARAMETER.Value OR Parameters!YOUR_PARAMETER.Value = "Both", 1, 0)
The set the type to integer and the value to 1. This will assign the value of 1 to records that your field matches the parameter or the parameter is both. This assumes that there are no other options however.
You could also map the parameter to your query and filter the query instead of using a filter on the dataset or tablix.
WHERE (YOUR_FIELD = #YOUR_PARAMETER or #YOUR_PARAMETER = 'Both')
1 Parameter (3 options): Person, Dog, All... created a field in sproc: FILTER which holds "ALL" for every cell.
expression
=(Fields!CLIENT_TYPE.Value = Parameters!CLIENT_TYPE.Value)
OR
(Parameters!CLIENT_TYPE.Value = Fields!FILTER.Value)
value
=true
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:
I have a table in ssrs 2008. This table has a row visibility expression like:
=IIF(max(Fields!VExpected.Value) <> "", 1, 0) +
IIF(max(Fields!MExpected.Value) <> "", 1, 0) +
IIF(max(Fields!PExpected.Value) <> "", 1, 0) = 3, false, true)
Sometimes the datasource returns no data, or the returned data is not matching with this expression. In this case what I see is that a table with borders and column names but no data on it like:
id Vex Mex Pex
However, I want to show it as
id Vex Mex Pex
- - - -
Or if possible:
id Vex Mex Pex
No Data
Another question is, is there any way to hide the complete table if there is no returning data or any matching data with the expression?
Thanks
You can use CountRows function to determine how many rows your dataset is returning. If it is zero hide the table otherwise show it.
=iif(CountRows("DataSetName")=0,true,false)
Replace DataSetName by the actual name of your dataset.
For not matching expression data you can use the this expression.
=IIF(
max(Fields!VExpected.Value) <> "" AND
max(Fields!MExpected.Value) <> "" AND
max(Fields!PExpected.Value) <> "",False,True
)
The whole expression for matching expression and no rows cases could be something like this:
=Switch(
CountRows("DataSetName")=0,true,
max(Fields!VExpected.Value) = "",true,
max(Fields!MExpected.Value) = "",true,
max(Fields!PExpected.Value) = "",True,
true,False
)
Supposing VM, ME and PE expected values are numeric type I'd use ISNOTHING() function to determine when null values are being returned.
=Switch(
CountRows("DataSetName")=0,true,
ISNOTHING(max(Fields!VExpected.Value)),true,
ISNOTHING(max(Fields!MExpected.Value)),true,
ISNOTHING(max(Fields!PExpected.Value)),True,
true,False
)
Additional you can set a message when no rows are being returned from your dataset. Select the tablix and press F4 to see properties window. Go to NoRowsMessage property and use an expression to say your users there is no data.
="There is no data."
In this cases the tablix will not appear in your report but the message you set will be rendered in the location where the tablix should be.
Let me know if this helps.
I've created a simple query in MDX to lookup a value. When i use this it works:
With
MEMBER [Measures].[dummy] as 1
select non empty {
[Measures].[dummy]
} on columns,
non empty {
except([Product].[Code].members, [Product].[Code].[All])
* except([Product].[Description].members, [Product].[Description].[All])
} on Rows
FROM
(SELECT Filter([Product].[Description].[Description].Members,
(InStr(1,[Product].[Description].CurrentMember.member_caption,"502080")>0))
ON COLUMNS
FROM [Cube])
but when i try to make this dynamic for use with MSRS it gives me an error:
"The SearchFor parameter could not be resolved because it was referenced in an inner subexpression"
This is my code with parameter:
With
MEMBER [Measures].[dummy] as 1
select non empty {
[Measures].[dummy]
} on columns,
non empty {
except([Product].[Code].members, [Product].[Code].[All])
* except([Product].[Description].members, [Product].[Description].[All])
} on Rows
FROM (
SELECT StrToMember
("Filter([Product].[Description].[Description].Members,
(InStr(1,[Product].[Description].CurrentMember.member_caption," + StrToMember(#SearchFor) + ")>0))")
on Columns
FROM [Cube])
Who knows how to get around this error? Please point me into the right direction.
Thanks in advance.
The way in which you use the parameter is as a simple string, not as a member reference. Hence, just leave away the StrToMember so that the FROM clause gets
FROM
(SELECT Filter([Product].[Description].[Description].Members,
(InStr(1,[Product].[Description].CurrentMember.member_caption, #SearchFor)>0))
ON COLUMNS
FROM [Cube])
It is difficult to check this without access to your cube.
However, to check the logic of the expression, you could issue a query like this:
WITH MEMBER Measures.[test0] as
#SearchFor
MEMBER Measures.[test1] as
InStr(1,[Product].[Description].CurrentMember.member_caption, #SearchFor) > 0
SELECT { Measures.[test0], Measures.[test1] } on columns,
{
[Product].[Description].[ABC],
[Product].[Description].[DEF],
[Product].[Description].[GHI],
[Product].[Description].[JKL]
} on rows
FROM [Cube]
You should replace the product list with some products really existing in your cube, some which fulfill the search criteria, and some that do not. Then you should be able to see True and False in the last column, depending if the match with the search criteria is successful or not. And the column to the left of it should display your search parameter in all rows.
It turned out my report would not show the data i retrieved with my MDX query. I started over with a new dataset:
With
MEMBER [Measures].[ParameterCaption] AS [Product].[Description].CURRENTMEMBER.MEMBER_CAPTION
MEMBER [Measures].[ParameterValue] AS [Product].[Description].CURRENTMEMBER.UNIQUENAME
MEMBER [Measures].[ParameterLevel] AS [Product].[Description].CURRENTMEMBER.LEVEL.ORDINAL
select {
[Measures].[ParameterCaption], [Measures].[ParameterValue], [Measures].[ParameterLevel]
} on columns,
EXCEPT([Product].[Description].MEMBERS,[Product].[Description].[All]) *
EXCEPT([Product].[Code].MEMBERS,[Product].[Code].[All])
ON ROWS
FROM ( SELECT FILTER ([Product].[Description].Members,
(InStr ([Product].[Description].CurrentMember.Name,
#SearchFor) <> 0)) ON COLUMNS FROM [Cube])
After adding a new tablix in my report the filter works as expexted. I still have no idea why my previous MDX wasn't working with the report.