I have two measure groups in cube:
Facts1 (id1, measure1, dim1, dim2)
Facts2 (id2, measure2, dim1, dim2)
And I have two dimensions:
Dim1
Dim2
All is fine.. In the finall cube I have two measures and two dimensions.
Now I want to use Dim2 as role-playing dimensions:
Dim2A
Dim2B
So now, my fact tables are:
Facts1 (id1, measure1, dim1, dim2a, dim2b)
Facts1 (id2, measure2, dim1, dim2a, dim2b)
But in finall cube instead of having
Dim1
Dim2A
Dim2B
..I've got
Dim1
Dim2A (Facts1)
Dim2B (Facts1)
Dim2A (Facts2)
Dim2B (Facts2)
Where did I make a mistake?
How to tell SASS that:
Dim2A (Facts1) and Dim2A (Facts2) is the same dimension;
Dim2B (Facts1) and Dim2B (Facts2) is the same dimension?
Found!
I had to go to cube editor, Dimension Usage tab.
I had to delete Dim2A (Facts2) and Dim2B (Facts2) and then to define a missing relation for Dim2A (Facts1) and Dim2B (Facts1) with Facts2 measure group, by clicking dots [...] in empty cell on intersecion of Facts2 column and Dim2A, Dim2B rows.
Related
I have an OLAP cube via SSAS and I would like to create a calculated measure which will be calculated upon several conditions.
I have a Time dimension and a Dimension1 containing a MinMonthId attribute.
The new measure has to be calculated only after the MinMonthId so I create the measure like this :
NewMeasure = IIF([TimeDimension].[MonthId].currentmember.MemberValue < [Dimension1].[MinMonthId].currentmember.MemberValue, NULL, [Measures].[MeasureA] - [Measures].[MeasureB]);
It works if MinMonthId appears in the reporting but it doesn't work otherwise, it's empty
Any Idea ?
FactTable :
Dim1_ID (linked to Dimension1.Dim1_ID)
Month_ID (linked to TimeDimension.MOnthId)
MeasureA
MeasureB
TimeDimension (with hierarchy MonthId -> YearId)
MonthId
YearId
Dimension1:
Dim1_ID
MinMonthId
I have two measures in cube. I want to add two values from each measure and showing into one measure. basically adding two measure values into one.
How can I do.
thanks
To create a new measure which sums two other measures:
WITH MEMBER [Measures].[MyNewMeasure] AS [Measures].[MyFirstMeasure] + [Measures].[MySecondMeasure]
SELECT {[Measures].[MyNewMeasure]} ON COLUMNS,
{ whatever } ON ROWS
FROM [CubeName]
I have a requirement to display the measures of a cube in hierarchy (browsing in excel or SSRS). Say I have four measures in fact table revenue A, revenue B, expense A. I need to show it as
'+ Profit (calculated measure)
'--+Revenue (calculated measure)
'----+Revenue A (Fact measure)
'----+Revenue B (Fact measure)
'--+expense (calculated measure)
'----+Expense A (Fact measure)
'----+Expense B (Fact measure)
I created the calculated measure however I am unable to solve the hierarchy issue for the measures. I am not able to use Display folders or degenerate dimensions to achieve the result. Can anyone help?
You don't need to create a hierarchy if the purpose is just to be able to browse it. Create a named set in your cube(if changing cube structure is an option), or a query scoped named set(if it should be temporarily created) and put all the requisite measures into it.
WITH SET MySetOfMeasures AS
{
Measures.Profit,
Measures.Revenue,
Measures.[Revenue A],
Measures.[Revenue B],
Measures.expense,
Measures.[Expense A],
Measures.[Expense B]
}
Then you can invoke this set in your MDX.
SELECT MySetOfMeasures ON 0 FROM [YourCube]
In my product dimension, I have an attribute called CustomerRating which is a string. Possible values are "1", "2", "3", and "4".
I want to turn this attribute into a Measure that averages ratings for collections of products.
with member [Measures].[Product Rating] as
( [Product].[Project Name].CurrentMember.Properties("CustomerRating"))
select [Measures].[Product Rating] on columns
from [MyCube]
This query produces an error - I suspect because I'm dealing with a string.
How do I turn customer rating into a measure that is an average rather than a sum?
The best approach would be to add an int column to the source table of the dimension, maybe just as a named calculation in the DSV. Then you would add a measure group on the dimension table, and define a measure rating_sum that sums this column, and a count measure in this measure group.
Then define a calculated measure as rating_sum / count.
If everything works, make the two measures rating_sum and count invisible.
Not tested but I'm wondering if this errors?
WITH
MEMBER [Measures].[Product Rating] AS
CInt([Product].[Project Name].CurrentMember.Properties("CustomerRating"))
SELECT
{[Measures].[Product Rating]} ON COLUMNS
From [MyCube]
I’m pretty new to the many-to-many dimensions but I have a scenario to solve, which raised a couple of questions that I can’t solve myself… So your help would be highly appreciated!
The scenario is:
There is a parent-child Categories dimension which has a recursive Categories hierarchy with NonLeafDataVisible set
There is a regular Products dimension, that slices the fact table
There is a bridge many-to-many ProductCategory table which defines the relation between the two. Important to note is that a product can belong to any level of the categories hierarchy – i.e. a particular category can have both – directly assigned products and sub-categories.
There is a fact Transactions table that holds a FK to the Product that has been sold, as well as a FK to its category. The FK is needed, because
I have all this modeled in BIDS, the dimension usage is set between each of the dimensions and the facts, the many-to-many relation between the Categories and the Transactions table is in place is in place. In other words everything seems kind of OK..
I now need to write an MDX which I would use to create a report that shows something like that:
Lev1 Lev2 Lev3 Prod Count
-A
-AA 6
-AA 2
P6 1
P5 1
-AAA 2
P1 1
P2 1
-AAB 2
P3 1
P4 1
+BB
The following MDX almost returns what I need:
SELECT
[Measures].[SALES Count] ON COLUMNS,
NONEMPTYCROSSJOIN(
DESCENDANTS([Category].[PARENTCATEGORY].[Level 01].MEMBERS),
[Product].[Prod KEY].[Prod KEY].MEMBERS,
[Measures].[Measures].[Bridge Distinct Count],
[Measures].[SALES Count],
2) ON ROWS
FROM [Sales]
The problem that I have is that for each of the non-leaf categories, the cross join returns a valid intersection with each of the products that’s been sold for it + all subcategories. Hence the result set contains way too much redundant data and besides I can’t find a way to filter out the redundancies in the SSRS report itself.
Any idea on how to rewrite the MDX so that it only returns the result set above?
Another problem is that if I create a role-playing Category dimension which I set to slice directly the transactions data, then the numbers that I get when browsing the cube are completely off… It seems as SSAS is doing something during processing (but it’s not the SQL statements it shoots to the OLTP, as those remain exactly the same) that causes the problem, but I’ve no idea what. Any ideas?
Cheers,
Alex
I think I found a solution to the problem, using the following query:
WITH
MEMBER [Measures].[Visible] AS
IsLeaf([DIM Eco Res Category].[PARENTCATEGORY].CurrentMember)
MEMBER [Measures].[CurrentProd] AS
IIF
(
[Measures].[Visible]
,[DIM Eco Res Product].[Prod KEY].CurrentMember.Name
,""
)
SELECT
{
[Measures].[Visible]
,[Measures].[CurrentProd]
,[Measures].[FACT PRODSALES Count]
} ON COLUMNS
,NonEmptyCrossJoin
(
Descendants
(
[DIM Eco Res Product].[Prod KEY].[(All)],
,Leaves
)
,Descendants([DIM Eco Res Category].[PARENTCATEGORY].[(All)])
,[Measures].[FACT PRODSALES Count]
,2
)
DIMENSION PROPERTIES
MEMBER_CAPTION
,MEMBER_UNIQUE_NAME
,PARENT_UNIQUE_NAME
,LEVEL_NUMBER
ON ROWS
FROM [Sales];
In the report then I use the [Measures].[CurrentProd] as a source for the product column and that seems to work fine so far.