Hierarchy Level to display from than level down on SSRS Report - reporting-services

So I have a report with 4 parameters;
#LevelParameterCheat; Hierarchy Level, this is the level inside the cube
#DimOrganizationCustomerHierarchy; Organizational Level
#FromDimDateDateSK/#ToDimDateDateSK; used for filtering
Here is the DataSet MDX Query;
SELECT NON EMPTY { [Measures].[Count] } ON COLUMNS, NON EMPTY
{ (DESCENDANTS([Dim Organization].[Customer Hierarchy].Levels(#LevelParameterCheat).ALLMEMBERS) ) }
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME, PARENT_UNIQUE_NAME, LEVEL_NUMBER ON ROWS FROM ( SELECT (
STRTOSET("[Dim Organization].[Customer Hierarchy].&[" + #DimOrganizationCustomerHierarchy + "]", CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOMEMBER("[Dim Date].[Date SK].&[" + Format(#FromDimDateDateSK,"yyyyMMdd") + "]", CONSTRAINED) :
STRTOMEMBER("[Dim Date].[Date SK].&[" + Format(#ToDimDateDateSK,"yyyyMMdd") + "]", CONSTRAINED) )
ON COLUMNS FROM [Portal Data Mart])) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
What I need: At time of execution the user knows his Org Level and dates to filter. The report needs to display all data from the selected Org Level down.
What I’m looking for; I need to somehow use the Org Level to query the cube and look for the specific level of the selected Org and plug it in the DECENDANTS Function so it displays only from that level on.
What I’ve done; ….ahhhhgggg to many trials and errors . The latest was to try and get the level doing something like this…
WITH MEMBER MEASURES.LevelNumber AS [Dim Organization].[Customer Hierarchy].&[#DimOrganizationCustomerHierarchy].Level.Ordinal
And if that worked I assumed it would bring a numeric value of the level that I then have to concatenate with the DECENDANTS command, something like this…
{ (DESCENDANTS(STRTOSET("[Dim Organization].[Customer Hierarchy].Levels(“level “" + LevelNumber + ").ALLMEMBERS)"))}
Well, something is not right because it doesn’t work. I’m very new to MDX and lacking on the syntax so if someone can point me in the right direction I would appreciate it very much. So far the query above works on the report because I manually enter the Org/Level combination but the user would not know what their Level is. I’ve been at it for almost two weeks and need to fix this. I feel I’m close but not there yet. Please help

well here is the answer to the problem;
`SELECT NON EMPTY { [Measures].[Count] } ON COLUMNS, NON EMPTY
{ (DESCENDANTS(StrToMember( "[Dim Organization].[Customer Hierarchy].&[" + #DimOrganizationCustomerHierarchy + "]",CONSTRAINED).Level.ALLMEMBERS) ) }
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME, PARENT_UNIQUE_NAME, LEVEL_NUMBER ON ROWS FROM ( SELECT (
STRTOSET("[Dim Organization].[Customer Hierarchy].&[" + #DimOrganizationCustomerHierarchy + "]", CONSTRAINED) ) ON COLUMNS FROM ( SELECT (
STRTOMEMBER("[Dim Date].[Date SK].&[" + Format(#FromDimDateDateSK,"yyyyMMdd") + "]", CONSTRAINED) :
STRTOMEMBER("[Dim Date].[Date SK].&[" + Format(#ToDimDateDateSK,"yyyyMMdd") + "]", CONSTRAINED) )
ON COLUMNS FROM [Portal Data Mart])) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS`

Related

How to get previous month data in MDX

I am trying to get previous month data for my SSRS report.But i am not getting any result.Could you please give any help.Below is my query.
SELECT
NON EMPTY
{[Measures].[Trade Net Amount]} ON COLUMNS
,NON EMPTY
{
[Fund].[Fund Name].[Fund Name].ALLMEMBERS*
[Transaction Type].[Transaction Description].[Transaction Description].ALLMEMBERS*
[Calendar Day].[Year].[Year].ALLMEMBERS*
[Calendar Day].[Month].[Month].ALLMEMBERS
}
DIMENSION PROPERTIES
MEMBER_CAPTION
,MEMBER_UNIQUE_NAME
ON ROWS
FROM
(
--FROM ( SELECT ( STRTOSET(#CalendarDayMonth, CONSTRAINED) ) ON COLUMNS
--FROM ( SELECT ( STRTOSET(#CalendarDayYear, CONSTRAINED) ) ON COLUMNS
SELECT
StrToMember
(
"[Calendar Day].[Calender Hierarchy].[Month].[" + Format(Now(),"yyyy")
+
Format
(
Now()
,"MMM"
)
+ "].PrevMember"
) ON COLUMNS
FROM [Escher_Hybrid]
);

passing parameter in mdx query

What I am trying to do is; User would select value of region from the dropdown(Region1, Region2, Region3).
#Region should take that value in the mdx query.
for eg. if user selects Region2, it should look like: [Region].[Region2].children. The query that I have written shows that there's a syntax error.
WITH
MEMBER [measures].[region] AS
StrToMember("[Region].[" + #Region + "]").CurrentMember.Name
MEMBER [measures].[product] AS
[Product Line].[product Line L2].CurrentMember.Name
SELECT
NonEmpty
(
StrToMember("[Region].[" + #Region + "]").Children
*
[Product Line].[Product Line L2].Children
,[Measures].[Total Clients]
) ON ROWS
,{
[measures].[region]
,[measures].[product]
,[Measures].[Total Clients]
} ON COLUMNS
FROM [EQ Coverage];
You also have available the function strToSet so this:
StrToMember("[Region].[" + #Region + "]").Children
Could be written as:
StrToSet("[Region].[" + #Region + "].Children", CONSTRAINED)
BUT I'm unsure of the purpose of this part of your code?
MEMBER [measures].[region] AS
StrToMember("[Region].[" + #Region + "]").CurrentMember.Name
I don't see the purpose of using the parameter - you could do something like this?
MEMBER [measures].[region] AS
[Region].[Region].CurrentMember.member_caption

SSRS The restrictions imposed by the CONSTRAINED flag in the STRTOSET function were violated

I got a problem using Multi-Value Parameters in SSRS.
I got a DataSet with this MDX Query :
SELECT NON EMPTY { [Measures].[Air Temperature Out - Fact Germination
Continue] } ON COLUMNS, NON EMPTY { ([81 Germination Continue].[Batch
Number].[Batch Number].ALLMEMBERS * [80 Germination General].[Plant
Name].[Plant Name].ALLMEMBERS * [80 Germination General].[Production
Unit].[Production Unit].ALLMEMBERS * [81 Germination
Continue].[Characteristic Date].[Characteristic Date].ALLMEMBERS * [80
Germination General].[Start Date Unloading].[Start Date
Unloading].ALLMEMBERS * [80 Germination General].[Start Date].[Start
Date].ALLMEMBERS * [80 Germination General].[End Date].[End
Date].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION,
MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT (
STRTOSET(#GerminationGeneralProductionUnit, CONSTRAINED) ) ON COLUMNS
FROM ( SELECT ( STRTOSET(#GerminationGeneralPlantName, CONSTRAINED) )
ON COLUMNS FROM ( SELECT ( STRTOSET(#GerminationContinueBatchNumber,
CONSTRAINED) ) ON COLUMNS FROM [Supervision]))) CELL PROPERTIES VALUE,
BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME,
FONT_SIZE, FONT_FLAGS
When running the report, I got the error :
The restrictions imposed by the CONSTRAINED flag in the STRTOSET
function were violated.
From my research, this means I have to put the full name in the parameters of the DataSet. The thing is that I think I did it, even if it's a bit different from what I saw, because of the construction of the datasets. For example, for the Germinaction Continue Batch Number, my parameter value is :
=Split(Replace(Join(Parameters!BatchNumbers.Value, ","), "[70 Steeping General]", "[81 Germination Continue]"), ",")
As you can guess, my data come from the dimension "[70 Steeping General]", which I try to put in the dimension "[81 Germination Continue]", the values are the same in both dimension ([81 Germination Continue].[Batch Number].[Batch Number] and [70 Steeping General].[Batch Number].[Batch Number]
Does the problem come from the fact that it's a multi-value parameter that looks like this? :
[81 Germination Continue].[Batch Number].[1234567890],
[81 Germination Continue].[Batch Number].[1234567891],
[81 Germination Continue].[Batch Number].[1234567892]
EDIT :
The parameters of the report :
FromSteepingStartDate
ToSteepingStartDate
Both are Date/Time parameters and have an available value set to None, Default Value is DateAdd("m", -1, Today()) and DateAdd("d", -2, Today())
They are used in the DataSet DataSteeping, and the value of the parameter is
="[70 Steeping General].[Start Day].&[" + CStr(Format(CDate(Parameters!FromSteepingGeneralStartDay.Value),
"yyyy-MM-dd"))+ "T00:00:00]"
SteepingGeneralPlantName
This parameter is a multi-value parameter, that initialy come from my dataset DataSteeping, so an autogenerated dataset has been created, with the following query :
WITH MEMBER [Measures].[ParameterCaption] AS [70 Steeping
General].[Plant Name].CURRENTMEMBER.MEMBER_CAPTION MEMBER
[Measures].[ParameterValue] AS [70 Steeping General].[Plant
Name].CURRENTMEMBER.UNIQUENAME MEMBER [Measures].[ParameterLevel] AS
[70 Steeping General].[Plant Name].CURRENTMEMBER.LEVEL.ORDINAL SELECT
{[Measures].[ParameterCaption], [Measures].[ParameterValue],
[Measures].[ParameterLevel]} ON COLUMNS , [70 Steeping
General].[Plant Name].ALLMEMBERS ON ROWS FROM [Supervision]
The dataset is filtered like Parameter.Level <> 0 and Parameter.Caption <> "Unknown"
This parameter is used in every other DataSet, but they don't all come from the same dimension, so the parameter value in the others datasets properties looks like this:
=Split(Replace(Join(Parameters!SteepingGeneralPlantName.Value, ","), "[70 Steeping General]", "[80 Germination General]"), ",")
SteepingGeneralProductionUnit
This parameter is a multi-value parameter too, that initialy come from my dataset DataSteeping, so an autogenerated dataset has been created, but I changed it, so now it doesn't come from my dimension [70 SteepingGeneral], but from [04 Productions Unit], which contains all the productions unit, and is compatible with all the other dimensions, so it was easier to load in the other datasets, the MDX query is :
WITH MEMBER [Measures].[ParameterCaption] AS [04 Production
Units].[Production Unit].CURRENTMEMBER.MEMBER_CAPTION MEMBER
[Measures].[ParameterValue] AS [04 Production Units].[Production
Unit].CURRENTMEMBER.UNIQUENAME MEMBER [Measures].[ParameterLevel] AS
[04 Production Units].[Production Unit].CURRENTMEMBER.LEVEL.ORDINAL
SELECT {[Measures].[ParameterCaption], [Measures].[ParameterValue],
[Measures].[ParameterLevel]} ON COLUMNS , [04 Production
Units].[Production Unit].ALLMEMBERS ON ROWS FROM ( SELECT (
STRTOSET(#PlantsPlant, CONSTRAINED) ) ON COLUMNS FROM [Supervision])
The dataset is filtered like Parameter.Level <> 0
This parameter is used in every other DataSet, only my Dataset DataGermination need an expression for this parameter, because it's from another dimension :
=Split(Replace(Join(Parameters!SteepingGeneralProductionUnit.Value, ","), "[04 Production Units]", "[80 Germination General]"), ",")
TempSteepingLimit
This parameter is not important for the problem, it's just the temperature limit, which I need to display the duration where the temperature is above this limit. It's a text parameter that I convert to a float (with a replace so the user can type "," or "."). It has no dataset and is used in no one, just in a textbox expression.
BatchNumbers
This hidden parameter is populated by a DataSet which return all the batch numbers that match with the other parameters (From/To Steeping Start Date, Plant Name and Production Unit).
They are used in 2 DataSet (DataGermination and DataBatchProcessData), because I couldn't add the Steeping Start Date in those datasets.
In DataGermination, the value for BatchNumber is :
=Split(Replace(Join(Parameters!BatchNumbers.Value, ","), "[70 Steeping General]", "[81 Germination Continue]"), ",")
The dataset that populate this parameter is not autogenerated, I just added it, with this query :
SELECT NON EMPTY { [Measures].[Barley Volume] } ON COLUMNS, NON EMPTY
{ ([70 Steeping General].[Batch Number].[Batch Number].ALLMEMBERS *
[70 Steeping General].[Plant Name].[Plant Name].ALLMEMBERS * [70
Steeping General].[Production Unit].[Production Unit].ALLMEMBERS * [65
Batch Process Data].[Steeping Start Date].[Steeping Start
Date].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION,
MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT (
STRTOMEMBER(#FromSteepingGeneralStartDay, CONSTRAINED) :
STRTOMEMBER(#ToSteepingGeneralStartDay, CONSTRAINED) ) ON COLUMNS FROM
( SELECT ( STRTOSET(#SteepingGeneralProductionUnit, CONSTRAINED) ) ON
COLUMNS FROM ( SELECT ( STRTOSET(#SteepingGeneralPlantName,
CONSTRAINED) ) ON COLUMNS FROM [Supervision]))) CELL PROPERTIES VALUE,
BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME,
FONT_SIZE, FONT_FLAGS
(Sorry for my english)
Don't hesitate to ask questions!
Thank's for your help! :)

Passing multiple values to SSRS using MDX

I am running the following command for getting a multi value report
StrToSet
("[Dim Branch].[HierarchyB-T-C].[Trading Code].&[" +
Replace(
Join(
Parameters!TradingName.Value,"],"
) +"]",",",",[Dim Branch].[HierarchyB-T-C].[Trading Code].&["),",")
But I'm getting an error
'The Syntax for 'Join' is incorrect'.
I don't know what I am doing wrong. Can anyone correct me please?
If I change it to StrToSet(#TradingName, Constrained) it works for single value, but I'd like to pass multiple values.
Do you need curly braces to form a set? I have added one at the start of the below ... a little unsure where the end of your string is - does it end like this .&["?!
StrToSet(
"{[Dim Branch].[HierarchyB-T-C].[Trading Code].&["
+
Replace(
Join(Parameters!TradingName.Value,"],") + "]"
, ","
, ",[Dim Branch].[HierarchyB-T-C].[Trading Code].&["
)
,","
)
If Parameters!TradingName.Value is equal to a string of this format MEC,RSA then maybe join is not required:
StrToSet(
"{"
+
Replace(
"[Dim Branch].[HierarchyB-T-C].[Trading Code].&["
+
Parameters!TradingName.Value
, ","
,"],[Dim Branch].[HierarchyB-T-C].[Trading Code].&["
)
+
"]}"
,constrained)
To pass multiple value from parameter, i just followed the steps
1 Add parameters and name it like
Under dataset properties (shared dataset properties as well) , the Parameters tab write an expression like this way
=Split(Parameters!TradingName.Value,",")
in Shared dataset, write the MDX with WHERE (StrToSet(#TradingName))
SELECT
{[Total]} ON COLUMNS
,
{
[Dim Account].[Account Type].&[Income]
}
*
STRTOMEMBER("[Dim Fiscal Year].[HierarchyFiscal].[E Month].&[" + #FiscalYear +"]&[" + FORMAT(Now(),"MMMM") +"].PREVMEMBER")
*
ORDER
(
{
[Dim Branch].[Branch Name].[Branch Name]
},[Total], BDESC
)
ON ROWS
from [CubeProfitLoss]
WHERE (StrToSet(#TradingName))
when you want to preview the multiple value, make sure you are using , to separate trading name likewise

Parameterized MDX query in SSRS 2008 with Multiple Rank Columns

I'm struggling to figure this one out and was hoping someone out there might be able to help.
I have an SSRS (2008) report that connects directly to an SSAS OLAP Cube. I have 5 different columns, each showing a different measure, broken out by the "Manager" dimension. I also have parametrized dropdowns in SSRS that filter the data based on various things.
Here's the code that got me to this point:
SELECT
NON EMPTY{
[Measures].[Metric A]
,[Measures].[Metric B]
,[Measures].[TMetric C]
,[Measures].[Metric D]
,[Measures].[Metric E]
} ON COLUMNS
,NON EMPTY{
([Ops Hierarchy].[Manager].[Manager].ALLMEMBERS )
} DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM
(
SELECT
(
STRTOSET(#CompleteDateCalendar, CONSTRAINED) ) ON COLUMNS
FROM
(
SELECT
(
STRTOSET(#City, CONSTRAINED) ) ON COLUMNS
FROM
(
SELECT
(
STRTOSET(#Region, CONSTRAINED) ) ON COLUMNS
FROM
(
SELECT
(
STRTOSET(#Country, CONSTRAINED) ) ON COLUMNS
FROM
[CUBE]
)
)
)
)
WHERE
(
IIF( STRTOSET(#Country, CONSTRAINED).Count = 1, STRTOSET(#Country, CONSTRAINED)
, [Ops Hierarchy].[Division Name].currentmember )
, IIF( STRTOSET(#Region, CONSTRAINED).Count = 1, STRTOSET(#Region, CONSTRAINED)
, [Ops Hierarchy].[Region Name].currentmember )
, IIF( STRTOSET(#City, CONSTRAINED).Count = 1, STRTOSET(#City, CONSTRAINED)
, [Ops Hierarchy].[System Name].currentmember )
, IIF( STRTOSET(#CompleteDateCalendar, CONSTRAINED).Count = 1, STRTOSET(#CompleteDateCalendar, CONSTRAINED)
, [CompleteDate].[Calendar].currentmember )
)
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
And of course, SSRS automagically created the corresponding dropdowns for each #parameter.
Now, here's where I need help:
I have a new requirement to add a "Rank" column for each metric. So, for example, next to the "Metric A" column, there will be another column called "Metric A Rank" that ranks the manager on that row against the other managers that are showing on the report (based on the parameters selected in the dropdowns).
Now, I know that I can add:
WITH
SET [OrderedSet1] AS ORDER(FILTER([Ops Hierarchy].[Manager].MEMBERS,[Measures].[Metric A] <> NULL),[Measures].[Metric A],BASC)
MEMBER [Measures].[Metric A Rank] AS RANK([Ops Hierarchy].[Manager].CurrentMember,[OrderedSet1])
SET [OrderedSet2] AS ORDER(FILTER([Ops Hierarchy].[Manager].MEMBERS,[Measures].[Metric B] <> NULL),[Measures].[Metric B],BASC)
MEMBER [Measures].[Metric B Rank] AS RANK([Ops Hierarchy].[Manager].CurrentMember,[OrderedSet2])
etc, to the top of the MDX query, and then reference [Measures].[Metric A Rank] and [Measures].[Metric B Rank] in my select statement.
What I don't know how to do is filter the sets with the SSRS dropdowns so that I'm ranking against only what is showing on the report.
So for example, if someone has Country="USA", Region = "South", City = "Atlanta" and CompleteDate = "Jan 2012" selected in SSRS, and I rank Metric A against OrderedSet1, then I only want to show how each manager ranks against other managers in Atlanta for Jan 2012.
How do I "parameterize" the sets in the WITH clause using the SSRS dropdowns so that I'm only ranking against the subset that the user has selected?
Thanks in advance for your help!
in Set declaration you can use
SET [OrderedSet1] AS ORDER(FILTER([Ops Hierarchy].[Manager].MEMBERS*
[Ops Hierarchy].[System Name].currentmember
,[Measures].[Metric A] <> NULL),[Measures].[Metric A],BASC)