MDX - Drill down in a hierarchy to the last level having the member caption containing "#" - ssas

I have a UserHierarchy, and when the member caption of the current level contains a "#" in the name, is resembles a particular user type. The UserHierarchy, contains up to 5 levels.
I would like to display drilled down data, but only for these particular user types, hence only those captions which have "#". I would also want to aggregate the children's data.
Is there a simple way in MDX to accomplish this?
Example :
#User1 €2
---#User2 €6
---------User4 €9
---------User5 €4
---#User3 €2
---------User6 €4
---------User7 €4
I would like to display figures, for themselves and children like this. To understand, I included where the figures were obtained from :
#User1 €2
---#User2 €19 (Obtained from : €6 + €9 + €4)
---#User3 €10 (Obtained from : €2 + €4 + €4)

select [Measures].[Internet Sales Amount] on columns,
non empty(
distinct(
descendants({[Product].[Category].children}) *
{filter([Product].[Subcategory].members,
instr([Product].[Subcategory].currentmember.member_caption, 'T') = 1)
}
* descendants({[Product].[Product].children})
)
)
on rows from cube
Result with detailed info:
"Second result:
Here i have deleted the row:
* descendants({[Product].[Product].children})
I think that´s what you want since it shows the totals of the children.
You need to exchange the 'T' for your '#' then also the dimension names and what you want to show as a measure.

Related

how to avoid the error "Category member XXX defined as an empty set" in icCube?

I've got the following MDX code to create a category dimension with 4 members:
all members that make up of 0-50% of the measure (TopPercent)
members 50-80%
members 80-95%
members 95-100%
The code works perfectly on levels with a lot of members:
WITH
MEMBER [measures].[v] as eval([Tijd].[Tijd].[jaar].[2018],[Measures].[Bedrag])
set [selection] as Order( nonempty([Categorie].[Categorie].[categorie].members,[measures].[v]), [measures].[v], BDESC)
CATEGORY HIERARCHY [Stats].[ABCD], DEFAULT_MEMBER_NAME = "Totaal", LEVEL_NAME_PATTERN="L - ABCD - ${levelDepth}"
CATEGORY MEMBER [Stats].[ABCD].[Totaal].[A (0-50%)] as
TopPercent([selection],50, [measures].[v] ), ADD_CHILDREN=true
CATEGORY MEMBER [Stats].[ABCD].[Totaal].[B (50-80%)] as
TopPercent([selection],80, [measures].[v] )
- TopPercent([selection],50, [measures].[v]), ADD_CHILDREN=true
CATEGORY MEMBER [Stats].[ABCD].[Totaal].[C (80-95%)] as
TopPercent([selection],95, [measures].[v])
- TopPercent([selection],80, [measures].[v] ), ADD_CHILDREN=true
CATEGORY MEMBER [Stats].[ABCD].[Totaal].[D (95-100%)] as
Order([selection], [measures].[v], BDESC)
- TopPercent([selection],95, [measures].[v]), ADD_CHILDREN=true
SELECT
// Measures
{[measures].[v]} On 0,
// Columns
[Stats].[ABCD].[L - ABCD - 1].members on 1,
// Rows
[Stats].[ABCD].[L - ABCD - 2].members on 2
FROM (select [Tijd].[jaar].[2018] on 0 from [Spendzoom])
/*ic3navigation*/
But when I run the MDX code with:
set [selection] as Order( nonempty([Categorie].[Categorie].[type].members,[measures].[v]), [measures].[v], BDESC)
I get the error: Category member "[Stats].[ABCD].[Totaal].[C (80-95%)]'defined as an empty set.
I have tried to rewrite the definitions, as:
subcubeminus(TopPercent .... , TopPercent)
But that gave completely strange results.
How can I overcome this error and have a generic approach that allways works regardless of the contents of the hierarchy & level in the [selection] definition?
To understand what happening you should check how TopPercent works (it's not really whay you expected).
Try this MDX :
WITH
MEMBER [measures].[v] as eval([Tijd].[Tijd].[jaar].[2018],[Measures].[Bedrag])
STATIC SET [selection] as [Categorie].[Categorie].[categorie].members
SELECT
[measures].[v] On 0,
TopPercent([selection],95, [measures].[v]) on 1,
TopPercent([selection],80, [measures].[v] ) on 2
FROM
(select [Tijd].[jaar].[2018] on 0 from [Spendzoom])
As you see both return the same set, and that is not what you are looking I guess.
As ic3 mentioned in the comments, as of icCube 6.8.10, icCube allows now to have empty categories. Y
For me this means, business wise, that regardless of the global filter settings the categories ALWAYS work. In case it is an empty set, it results a blank value in the dashboards.
example of a Parato analysis for just 1 vendor (bedrag = amount, #Fact = nr of invoices, #Lev = nr of suppliers)
Exactly as desired.

MDX,how to flatten the result of Descendants function

I have a hierarchy with 5 level,I use Descendants() to retrieve all lower level of a member.But i end up with a one column result where i like to have a result with one column for each level.So on each row i repeat the parent,grand parents etc of the current member.
WITH
MEMBER [Measures].[key] AS
[DimGLAcct].[MgtCOA].CurrentMember.UNIQUENAME
MEMBER [Measures].[level_] AS
[DimGLAcct].[MgtCOA].CurrentMember.level.ordinal
SELECT
{
[Measures].[key]
, [Measures].[level_]
, [Measures].[Actuals]
} ON COLUMNS,
{
Descendants(
[DimGLAcct].[MgtCOA].[Mparent5].&[MCOA].&[400000M - Total operating overhead expenses].&[440000M - Other expenses].&[441000M - Other expenses]
,
,SELF_AND_AFTER
)
} ON ROWS
FROM [Model];
I cannot quite suss out the names of your levels but it is ok to do the following in mdx:
WITH
MEMBER [Measures].[key] AS
[DimGLAcct].[MgtCOA].CurrentMember.UNIQUENAME
MEMBER [Measures].[level_] AS
[DimGLAcct].[MgtCOA].CurrentMember.level.ordinal
SELECT
{
[Measures].[key]
, [Measures].[level_]
, [Measures].[Actuals]
} ON COLUMNS,
[DimGLAcct].[LevelX]
*[DimGLAcct].[LevelY]
*[DimGLAcct].[LevelZ]
*[DimGLAcct].[LevelK]
ON ROWS
FROM [Model];
Each of the levels in your user hierarchy will have respective attribute hieraries - which are used in the above.

Where Clause using another Dimension Value

I'm trying to create a Calculated Member in my cube with where clause but couldn't figure how to achieve the proper result.
I created a calculated member "Outlook" using the below code to display only Forecast values.
CREATE MEMBER CURRENTCUBE.[Measures].[Outlook]
AS SUM(([Source Profile].[Source Profile Hierarchy].CurrentMember,
[Source Profile].[Profile Level01].&[Outlook]),
[Measures].[USD Amount]),
FORMAT_STRING = "#,##0;(#,##0)",
VISIBLE = 1 , DISPLAY_FOLDER = 'USD' , ASSOCIATED_MEASURE_GROUP = 'CARS';
Cube Result
Now I would like to filter the results dynamically based on another hidden dimension "Current_Month". This dimension always has current financial period value and it's corresponding outlook profile
Year_Month Outlook_Profile
2015010 10 + 2
Expected result should be "Outlook" measure showing value based on Current_Month dimension, which is '10 + 2' and rest of them should be 0
Expected result
Just to explain the requirement in SQL terms, I would like to achieve the below in MDX
Where Fact.Source_Profile=Dimension.Source_Profile
instead of
Where Fact.Source_Profile='10 + 2'
I'm not sure how to achieve this in Where Clause or by another means. I could see examples of hard coding values, like year.&[2015] but haven't seen one using dynamic values.
I found a solution myself and thought of sharing the same. Used StrToMember function to pass hidden dimension's member as a variable here.
CREATE MEMBER CURRENTCUBE.[Measures].[Outlook]
AS (
Sum
(
(
[Source Profile].[Source Profile Hierarchy].CurrentMember,
strtomember("[Source Profile].[Source Name].&[" + [Outlook Profile].[Outlook Profile].&[1].Member_Caption + "]")
)
,[Measures].[USD Amount]
)
),
FORMAT_STRING = "#,##0;(#,##0)",
VISIBLE = 1 , DISPLAY_FOLDER = 'USD' , ASSOCIATED_MEASURE_GROUP = 'CARS' ;

SSAS: How can I create calculated member using multiple conditions on different hierarchy

I have problem with my SSAS Cube.
I have to implement basic calculation to my Cube:
sum(Ammount) where BOOK = "Assets" and CD_PRODUCT_L4 <> "LoanLoss"
My dimmension is in image below:
Dimension attributes: BOOK, CD_PRODUCT_L4, CD_PRODUCT_L5, ..
Hierarchy PROD: CD_PRODUCT_L4 - CD_PRODUCT_L5
CREATE MEMBER CURRENTCUBE.[Measures].[Principal Loans]
AS (
except(
[PLV PRH HDIM CB].[BOOK].&[ASSETS_ON],
[PLV PRH HDIM CB].[COD PRODUCT L4].&[51L4]
),
[Measures].[EOM PRINCIPAL_a])
The biggest thing is that conditions are not from same hierarchy level so I can't use except and I know no other way to implement this particular condition set
Please HELP, Thank you
Product dimmension model
I manage to solve the issue by adding hierarchy to my dimension which allowed me to use except as I wanted before but I'am not satisfied with this solution because it looks more like workaround then solution
CREATE MEMBER CURRENTCUBE.[Measures].[Principal Loans] AS
sum((except([PLV PRH HDIM CB].[Hierarchy BOOK].[BOOK].&[ASSETS_ON].children,[PLV PRH HDIM CB].[Hierarchy BOOK].[COD PRODUCT L4].&[51L4]),[Measures].[EOM PRINCIPAL_a]))
This is probably the closest example that I can provide you to what you need.
This, code below, is just one of about 50 or so Measures we have defined, ranging from Counts, Averages, Sums, Percentages, etc. We take a single DW value and perform at least 2 seperation calculations, most have 4 or more different calculations, from that one field.
CREATE MEMBER CURRENTCUBE.[Measures].[Count Previous Difference]
AS Case
// Test for current coordinate being on (All) member.
When [Date].[YearMonth].CurrentMember.Level Is [Date].[YearMonth].[(All)]
Then "NA"
Else
( [Date].[YearMonth].CurrentMember, [Measures].[Gross Count] )
-
( ParallelPeriod (
[Date].[YearMonth].CurrentMember.Level,
1,
[Date].[YearMonth].CurrentMember
),
[Measures].[Gross Count]
)
End,
FORMAT_STRING = "#,##0.00;-#,##0.00",
NON_EMPTY_BEHAVIOR = { [Gross Count] },
VISIBLE = 0 , ASSOCIATED_MEASURE_GROUP = 'Some Summary';
Keep in mind we also use our DW & Cube with SharePoint and SSRS reports.

MDX Filtering dimension members with result of other dimension

I would like to filter a dimension for cube security with some information that are in another dimension.
So - I have a dimension which holds some account Responsible (Account Number and the initials on the one responsible) and another Dimension with all accounts.
I would like to make sure, that a person only can see movements on the accounts on which they are responsible.
I can make the filtering work like this:
SELECT
{} ON 0
,{
Exists
(
Filter
(
[Accounts].[Accounts].[AccountNo]
*
[AccountResponsible].[AccountResponsible].[AccountNo]
,
[Accounts].[Accounts].Properties("key")
=
[AccountResponsible].[AccountResponsible].Properties("key")
)
,[AccountResponsible].[Responsible].&[MSA]
)
} ON 1
FROM mycube;
the problem is, that there are two columns, and I can't use that in cube security. Is there a way to rewrite this, so that I actually get only one column with the members that the user are allowed to see?
Try using the Extract function:
SELECT
{} ON 0
,
EXTRACT(
{
Exists
(
Filter
(
[Accounts].[Accounts].[AccountNo]
*
[AccountResponsible].[AccountResponsible].[AccountNo]
,
[Accounts].[Accounts].Properties("key")
=
[AccountResponsible].[AccountResponsible].Properties("key")
)
,[AccountResponsible].[Responsible].&[MSA]
)
}
,[Accounts].[Accounts] //<<HIERARCHY YOU WISH TO EXTRACT
) ON 1
FROM mycube;