New Named Set in SSAS used in Pivot Table - MDX - ssas

I created a New Named Set called DB III o. PE defined as DB III, Umlage HL, Umlage NV, Umlage UL .
When I use this new Set in a Pivot Tabel or in MDX I see the content of this Set and not his given name DB III o. PE.
Is there a possibility to see the given name instead of his content?
Example attached:
The set is created like this:
UPDATE:
I created also a measure called [Amount Standard Set] because before Set I needed first to multiply with -1 the Amount of Umlage HL, Umlage NV, Umlage UL .
The measure is defined as:
case
when [Kostenart Hierarchy].[Kostenart Hierarchy].currentmember= [Kostenart Hierarchy].[Kostenart Hierarchy].&[148]
then -1* [Measures].Amount
when [Kostenart Hierarchy].[Kostenart Hierarchy].currentmember= [Kostenart Hierarchy].[Kostenart Hierarchy].&[147]
then -1* [Measures].Amount
when [Kostenart Hierarchy].[Kostenart Hierarchy].currentmember= [Kostenart Hierarchy].[Kostenart Hierarchy].&[150]
then -1* [Measures].Amount
else Amount
end

I think it is behaving as it should. A set is several distinct members.
You require a custom member that is the amalgamation of your set.
Create a custom member called DB III o. PE Agg and define it as something like the following mdx:
`Aggregate([DB III o. PE])`
This is using the Aggregate function:
https://msdn.microsoft.com/en-us/library/ms145524.aspx
Create this custom member in the dimension where the elements of the set {DB III, Umlage HL, Umlage NV, Umlage UL} are found.
If you are using Excel 2013 you should have a option in the OLAP Tools menu "MDX Calculated Member.."

Related

MDX sum over various sets

I have a datacube with a dimension of a large number of academic courses. I would like to group the courses (create a set) by the name of the course (using filter and Inst), so that I can calculate some aggregate statistics. i.e. I would ultimately like a list of the number of people doing courses with those groupings (split later by their home geography).
I have four measures, which include
[Measures].[Achievements]
[Measures].[Starts]
[Measures].[Enrolments]
[Measures].[Leavers]
I have managed to make two sets:
CREATE SET [MyDataCube].[BA] AS
{FILTER(
[Aim].[Aim Title].[Aim Title].Members,
(InStr(1, [Aim].[Aim Title].CurrentMember.NAME, "BA ") <> 0)
)
}
GO
CREATE SET [MyDataCube].[BSc] AS
{FILTER(
[Aim].[Aim Title].[Aim Title].Members,
(InStr(1, [Aim].[Aim Title].CurrentMember.NAME, "BSc") <> 0)
)
}
And then I can query a single set:
SELECT
NON EMPTY [AccessCourses] DIMENSION PROPERTIES MEMBER_NAME ON ROWS,
NON EMPTY Hierarchize({DrilldownLevel({[Geography - Learner Home].[Learner Home].[All]})}) DIMENSION PROPERTIES MEMBER_NAME ON COLUMNS
FROM [MyDataCube]
But how can I get a table with [Geography - Learner Home].[Learner Home].[All] on the rows, with a sum of all [Bsc] and [BA] courses on the columns, like:
I would like to do this for [Measures].[Starts].
Something like the following maybe:
WITH
MEMBER [Aim].[Aim Title].[All].[BA] AS
AGGREGATE(
[BA]
)
MEMBER [Aim].[Aim Title].[All].[BSc] AS
AGGREGATE(
[BSc]
)
SELECT
NON EMPTY
[Geography - Learner Home].[Learner Home].MEMBERS ON ROWS,
NON EMPTY
{
[Aim].[Aim Title].[All].[BA]
,[Aim].[Aim Title].[All].[BSc]
} ON COLUMNS
FROM [MyDataCube]
WHERE [Measures].[Starts];

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.

WHERE clause in calculated member

I am facing some problem to calculate values from comparing dimension's value. I have 3 dimensions (Datatype, Customer, Product) and one measure (GrossSales).
What would be the MDX query if I want GrossSales for ProductID = 1,2,3 and Dataype = 4,5,6?
Here Datatype has relationship with GrossSales, Customer has relationship with GrossSales and Product has relationship with Customer.
I am trying this but doesn't work
CREATE MEMBER CURRENTCUBE.[Measures].Forecast_Gross_Sales AS
(
SELECT NON Empty [Measures].[Gross Sale]
FROM [Measures]
WHERE (
[Data Type].[ID].[ID] = 4
AND [Chain].[Customer ID] = [Measures].[Customer ID]
)
), VISIBLE = 1
, DISPLAY_FOLDER = 'Forecast'
, ASSOCIATED_MEASURE_GROUP = 'Data Types';
It looks like you are just getting started with MDX. There are some fundamental concepts that will help you get what you need. This comparison of SQL and MDX might be helpful. MDX uses the where clause as a slicer (to select certain dimension members) rather than a filter. You can't put member = somevalue in the where clause. And you can't really use the where clause to define a relationship to some other table.
Instead, your where clause would be something more like
[Data Type].[ID].[ID].&[4]
Since I can't see your data model, I can't be sure, but I would guess that [Chain].[Customer ID] = [Measures].[Customer ID] is something that you want to define the the dimension usage of your cube rather than in the query.
Edit: Now that the question has been edited, it looks like you are creating a calculated member. in this case there is no select or where clause. It will look more like this:
CREATE MEMBER CURRENTCUBE.[Measures].Forecast_Gross_Sales AS
Aggregate([Data Type].[ID].[ID].&[4], [Measures].[Gross Sale])
, VISIBLE = 1
, DISPLAY_FOLDER = 'Forecast'
, ASSOCIATED_MEASURE_GROUP = 'Data Types';
The relationship from the measure group through the Customer dimension to the Chain dimension is something that should be defined in the dimension usage. This is called a Reference dimension relationship.

Linq related table not queryable error

I've got a problem with Linq in VB.NET.
I've created a .dbml file from my db, and everything looks good - relation "arrows" between tables are visible, etc.
But when I want to use simple query (taken from 101 Linq Samples by MS):
Dim q = From h In dc.Hours, w In h.WorkType
I receive an error:
Expression of type 'INTegrity.WorkType' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider.
h.Worktype is visible in Intellisense...
I can manually join in the Linq query, but shouldn't the relations be automatic?
The full query that works, but using "manual joins" looks like this:
Dim q1 = From g In dc1.Hours _
Join pr In dc1.WorkType On g.WorkTypeId Equals pr.WorkTypeId _
Where g.WorkerId = workerid _
Select New With {g.EntryId, g.Date, pr.WorkTypeDesc, g.Minutes}
Worktype table has 1 to many relationship with Hours table (as you can see on the WorkTypeId column)
I don't speak LINQ in VB, so I'll try to adapt to C#
From h In dc.Hours, w In h.WorkType
from h in dc.Hours
from w in h.WorkType
.....
This implies that WorkType is a collection, which it's name does not suggest. I think you want something closer to
from h in dc.Hours
let w = h.WorkType
....
Of course, none of these will do anything without the parts in the "....". If you show us what you want to do there, we could probably fix it for you.
UPDATE#1:
Trying to piece together what you are doing, let's guess that Hours & WorkType are tables with a one-to-many relationship (WorkType on the "one" side), hence every Hours record matchs one WorkType record. In that case, Linq-to-SQL will automatically generate a scalar WorkType property in Hours. You don't need the "from ... in " to access it. It's just a property, use it directly where you need it.
UPDATE#2: (From comments)
I think this should work:
Dim q1 =
From g In dc1.Hours
Where g.WorkerId = workerid
Select New With {g.EntryId, g.Date, g.WorkType.WorkTypeDesc, g.Minutes}