Issue in where condition while using in mdx - reporting-services

I have parameter value: 'Paris carlton' when 'm trying to pass this value in mdx as (StrTomember(#Parameter)) i'm getting error.
How to pass the total name 'Paris Carlton' in where condtn. to filter the parameter value.
when i tried:when pass this parameter value, it is considering only Paris and not Carlton thus resulting in error. how to consider the full name while passing a value in mdx?

If you are doing this :
(StrTomember(#Parameter))
Then #Parameter will need to be a string that represents the full member name. So you can either do an expression in SSRS to create a string that looks like this:
"[Geo Dimension].[Country hierarchy].&[Paris Carlton]"
Or you could build it inside the strToMember function:
(StrTomember("[Geo Dimension].[Country hierarchy].&[" + #Parameter +"]"))

Related

Index was outside the bounds of the array in SSRS

I have two parameters , let's say P1 and P2. The sample expression I used for P2 is
IIF(P1.Label="string", "null" ,Split(P1.Label," ").GetValue(0))
When the condition is false, the split expression is working fine. But if the condition is true, I'm getting 'Index was outside the bounds of the array' error. If the condition is true, I need to pass the value "null" as varchar type.
Can someone please advice on this?
The problem with the IIF function is that it is a function not a language construct. This means that it evaluates both parameters before passing the parameters to the function. Consequently, if you are trying to do a Split on a parameter that can't be split, you will still get the 'Index was outside the bounds of the array' error, even when it looks like that code shouldn't be executed due to boolean condition of the IIF statement.
The best way to solve this is to create a safe string splitter function in custom code where you can use real language constructs. Also, check that the string is splittable by checking it contains a space instead of checking for a special string:
Public Function SafeSplit(ByVal SplitThis As String) As String
If InStr(SplitThis, " ") Then
Return Split(SplitThis, " ")(0)
End If
Return "null"
End Function
and then use this in your report for the Value expression instead of IIF:
=Code.SafeSplit(Parameters!P1.Label)

ssrs filter tablix expression that will use parameter value to filter tablix

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

passing parameters in ado.net source

I wanted to pass a parameterized query in ado.net source and i rea don this post that only way to do this is to use expressions.
So here is my expression
"SELECT
LEDGER_YR_MO,
LOCATION,
FDR_FND_NO,
FDR_INVST_POOL_CD,
FISCAL_YR_BEG,
FISCAL_YR_END,
POST_DATE,
FDR_FND_TTL,
FDR_FND_TYPE_CD,
FDR_FND_PURP_CD,
FDR_CR_ELIG_FL,
FDR_ANN_CR_RATE,
FDR_MTH_CR_RATE,
FDR_CR_AMT,
FDR_TR_ELIG_FL,
FDR_ANN_TR_RATE,
FDR_MTH_TR_RATE,
FDR_60MTH_AVG_SHARE_PRC,
FDR_TR_AMT,
FDR_PROJ_GEP_INCM_AMT,
FDR_TR_AUGMENTATION_AMT,
FDR_GEP_NET_PAYOUT_AMT
FROM
FS0TST.UCOP_FDR_TR_CR where
LEDGER_YR_MO = '"+ (DT_WSTR,30) #[User::END_LEDGER_YR] +"' "
but when I click evaluate the expression , I see blank instead of variable ..does anyone know the possible issue:
Here is the evaluate expression looks like
SELECT
LEDGER_YR_MO,
LOCATION,
FDR_FND_NO,
FDR_INVST_POOL_CD,
FISCAL_YR_BEG,
FISCAL_YR_END,
POST_DATE,
FDR_FND_TTL,
FDR_FND_TYPE_CD,
FDR_FND_PURP_CD,
FDR_CR_ELIG_FL,
FDR_ANN_CR_RATE,
FDR_MTH_CR_RATE,
FDR_CR_AMT,
FDR_TR_ELIG_FL,
FDR_ANN_TR_RATE,
FDR_MTH_TR_RATE,
FDR_60MTH_AVG_SHARE_PRC,
FDR_TR_AMT,
FDR_PROJ_GEP_INCM_AMT,
FDR_TR_AUGMENTATION_AMT,
FDR_GEP_NET_PAYOUT_AMT
FROM
FS0TST.UCOP_FDR_TR_CR where
LEDGER_YR_MO = ''
When you click the Evaluate Expression button, no code actually gets executed, so the only thing SSIS can look at is the static default value you gave your variable.
If you want to see a value instead of a blank in the Evaluate Expression, you have to give your variable a default value, even if you don't intend to use that value. When the SSIS package is executed, whatever code you use to populate the variable will overwrite the default value, so having a default value is harmless.

SpagoBI OLAP report passing optional parameter

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:

SSRS Space Issue in Parameter Value

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.