I am hoping someone can help me with my latest hickup in design my mondrian schema. I use Mondrian 4, Pentaho along with Saiku analytics 3.7.
I am designing a performance metric system based on different KPI's which seems to be working fine. My problem is calculating ratio values in the mondrian schema where I need to lookup a specific dimension and then return the appropriate measure value for a given KPI calculation
<CalculatedMember name="Actual Performance" dimension="Measures">
<Formula>IIF([Performance].currentmember.name = 'Occupancy',
([Performance].currentmember.prevMember ,[Measures].[Actual Performance1])
, [Measures].[Actual Performance1])</Formula>
<CalculatedMemberProperty name="FORMAT_STRING" value="#,###"/>
<CalculatedMemberProperty name="DATATYPE" value="Numeric"/>
</CalculatedMember>
My question is this:
For the line of code above:
([Performance].currentmember.prevMember ,[Measures].[Actual Performance1])
How do I change or specify the (dimension) Performance Metric "Connected Time" to return the "Actual Performance" measure value instead of using the previous member/value?
In pseudocode I want this:
a) find dimension "Connected Time"
b) return the [Measures].[Actual Performance1] value for the "Connected Time" dimension
I actually need to calculate the ratio "Occupancy" As "Total Call Time" divided by "Connected Time" but just need a start for the dimension lookup.
Currently my line of code returns the previous member value as per the screenshot so I am guessing I am sort of on the righ track but stuck now as I am still learning Mondrian. I have lots of these KPI's that needs to be calculated this way.
I need to find a method of calculating the KPI ratios this way so cannot change the star schema the performance metric system is a complete balance scorecard approach for a call centre and works nicely except for getting the ratios calculated correctly.
Okay I have found a way to do this after a long struggle.
<CalculatedMember name="Actual Performance" dimension="Measures">
<Formula>
IIF
(
[Performance].currentmember.name = 'Occupancy',
(
([Performance].[Total Call Time] ,[Measures].[Actual Performance1]) / ([Performance].[Connected Time] ,[Measures].[Actual Performance1]) * 100
),
[Measures].[Actual Performance1]
)
</Formula>
<CalculatedMemberProperty name="FORMAT_STRING" value="#,###"/>
<CalculatedMemberProperty name="DATATYPE" value="Numeric"/>
</CalculatedMember>
Related
All of the measure that I want to cumulative has the same formula. So, is there any way to use the thing like function or any thing in calculate measure to resolve this issue?
There are two ways to achieve your aim:
1- the first solution is based on using the business intelligence wizard to add time intelligence to your solution.
The time intelligence enhancement is a cube enhancement that adds time calculations (or time views) to a selected hierarchy. This enhancement supports the following categories of calculations:
List item
Period to date.
Period over period growth.
Moving averages.
Parallel period comparisons.
The wizard will let you chose the calculations and measures you want to apply.
Visit : https://learn.microsoft.com/en-us/analysis-services/multidimensional-models/define-time-intelligence-calculations-using-the-business-intelligence-wizard
Visit : http://www.ssas-info.com/analysis-services-articles/62-design/2465-ssas-time-intelligence-wizard
2- Use a dimension table to calculate your calculations, this solution is more complicated, but very powerful and one of the best practices.
The first step is to create a new physical dimension, with real
members for each of the calculations we're going to need. We don't
actually need to create a table in our data warehouse for this
purpose, we can do this with an SQL view like this
CREATE VIEW DateTool AS SELECT ID_Calc = 1, Calc = 'Real Value' UNION ALL SELECT ID_Calc = 2, Calc = 'Year To Date'
Next, we need to add this view to our DSV and create a dimension based
on it. The dimension must have one hierarchy and this hierarchy must
have its IsAggregatable property set to False. The DefaultMember
property of this hierarchy should then be set to the Real Value
member. Giving this dimension a name can be quite difficult, as it
should be something that helps the users understand what it does –
here we've called it Date Tool. It needs no relationship to any
measure group at all to work.
Our next task is to overwrite the value returned by each member so
that they return the calculations we want. We can do this using a
simple SCOPE statement in the MDX Script of the cube:
this code let you create the YEAR-TO-DATE aggregation for all your measures.
SCOPE ([Date Tool].[Calculation].[Year To Date]); THIS = AGGREGATE ( YTD ([Date Order].[Calendar].CurrentMember), [Date Tool].[Calculation].[Real Value]); END SCOPE;
Visit:https://subscription.packtpub.com/book/big_data_and_business_intelligence/9781849689908/6/ch06lvl1sec35/calculation-dimensions
I am new to SSAS. I have a requirement, I need to calculate no of working days between user selected date range (either in Excel or SSRS or PowerBI). I found the MDX query, I need assistance with create a named calculation with MDX expression.
Date Dimension (Filtered):
MDX:
WITH MEMBER Measures.WorkingDays AS
COUNT
(
exists( EXISTING {[Dim Date].[Date].[Date].members}
, [Dim Date].[Is Weekday].&[1] )
)
Select {Measures.WorkingDays} on 0 ,
[Dim Date].[Month].[Month] on 1
from [Project Cube]
where ([Dim Date].[Date].&[2018-01-01T00:00:00]:[Dim Date].[Date].&[2018-04-25T00:00:00])
I need to add this named column on Fact table as measurement. I am having trouble with the below items:
Creating named query with MDX expression mentioned.
Adding a [Number of Working Days] as measure in Fact table.
Please correct me, If I am doing it in wrong way. My requirement is I need a [NoOfWorkingDays] as measure in fact table, so that I can use SSAS aggregate to use it as input on other measure, such as ([utilization%] = ([ActualDaysWorked] / [NoofWorkingDays]).
Note that, I can do analysis with the given MDX, but I need to deploy it with precalculated values in cube, so that end user can directly use the cube.
Kindly let me know, if more details required, Thank you.
Welcome to SSAS and MDX. Now to the answer.
I need to add this named column on Fact table as measurement. I am
having trouble with the below items:
Creating named query with MDX expression mentioned. Adding a [Number
of Working Days] as measure in Fact table.
You dont need to add it to the Fact table at all. Open your SSAS project, in your object explorer double click your cube. Now on the top left hand you will see a CALCULATIONS tab. In the CALCULATION tab, Click new calculated member, the icon has a calculator on it.
Please correct me, If I am doing it in wrong way. My requirement is I
need a [NoOfWorkingDays] as measure in fact table, so that I can use
SSAS aggregate to use it as input on other measure, such as
([utilization%] = ([ActualDaysWorked] / [NoofWorkingDays]).
If I remember correctly, the calculated members will not be added into the Aggregations, however the underlying measures would be. Secondly if you are wondering that you can use your calculated Measure in another calculated measure. The answer is yes you can use it in another calculated measure. So this is totally possible
> ([utilization%] = ([ActualDaysWorked] / [NoofWorkingDays])
where [utilization%] and [NoofWorkingDays] are calculated measures.
I am trying to get my head around how to design the SSAS tabular model for a scenario where I have an attribute on a dimension that will modify an otherwise straight-forward measure on a related fact table.
The fact table is currently at 155 million rows. The dimension has 6200 rows. The measure we need sums a unit volume fact, then multiplies that sum by a factor that belongs to the dimension. The context used for this measure has some constraints, then: the aggregation can never include multiple rows from the related dimension. It doesn't make any business sense to do so.
I started with this, which I know is wrong: =SUM([Unit Volume])*Products[Foo Factor], and of course the designer complains because the related attribute has many values without a specific context.
My work-around for now is to create a calculated column that brings the factor into the fact table: =RELATED(Products[Foo Factor]), and then I can create a measure that looks like this: =SUM([Unit Volume])*AVERAGE([Foo Factor]).
I don't like the idea of putting calculated columns on that fact table. It's huge and it only going to get bigger. I also don't like that there doesn't appear to be a way to put constraints on the context for a given measure so I can ensure the we don't roll up volume across multiple products. Or is there?
It seems to me that ours is not an unusual scenario, but I'm too new to DAX to know how to model it correctly. If I were in my familiar SQL world, I would use a windowing function like this:
select sum([Unit Volume]) over (partition by <context goes here>) as [Unit Volume Total]
Can I create something like this in a measure with DAX?
UPDATE
It seems like this should work, but the designer still barks:
=CALCULATE(SUM('My Facts'[Unit Volume])*Products[Foo Factor],FILTER(Products,Products[Product Code]="0"))
My thought was that the [Product Code]="0" filter would be replaced by the current context and since [Product Code] is defined as the key on the related table, SSAS would know my intent. Alas, it doesn't.
I think I may have it. Seems like I may not be able to get away from using an AVERAGE aggregation on the foo factor, but the HASONEVALUE function does enforce the constraint I want.
This should work:
=
IF (
HASONEVALUE ( Products[Product Code] ),
SUM ( 'My Facts'[Unit Volume] ) * AVERAGE ( Products[Foo Factor] ),
SUM ( [Unit Volume] )
)
Please try this:
=CALCULATE((SUM(My Facts[Unit Volume])*Products[Foo Factor]),Products[Product Code]=0)
Also please confirm Product Code format.
I am having some issues trying to implement an average of a dimension attribute.
The basic structure is:
Booking Header Dimension
Fact Table (multiple rows per Booking Header
entry)
On the booking header dimension I have a numerical attribute called Booking Window, and I want to be able to create a calculated measure that averages this value.
We are using SQL Server 2012 standard edition.
Any help would be greatly appreciated.
The best approach would be to create a measure group from the dimension table (in BIDS, go to cube designer, tab "Cube Structure", right-click the cube object in the Measures list, and select "New Measure Group", select your dimension table). BIDS will generate some measures, and you can remove all but two: the one based on your numeric attribute (I will call it "YourSummedAttrib" to have a name to refer to below), and the count measure. The aggregate function for the measure "YourSummedAttrib" will probably be "sum", leave that as it is.
Then, create a calculated measure which divides "YourSummedAttrib" by the count measure, which gives the average. Finally, if you have tested everything, make the two measures "YourSummedAttrib" and the count measure invisible before you give the cube to the users, as they only need to see the average, which is the calculated measure.
You can try this which should give you the average of that attribute across all members.
WITH MEMBER [Measures].[Booking Window Value] AS
[Booking Header].[Booking Window].CURRENTMEMBER.MEMBER_VALUE
MEMBER [Measures].[Avg Booking Window Value] AS
AVG([Booking Header].[Booking Window].[Booking Window].MEMBERS,[Measures].[Booking Window Value])
SELECT
[Measures].[Avg Booking Window Value] ON COLUMNS
FROM
[YourCube]
Hope that helps and apologies for any confusion on my part.
Ash
I tried to use the same idea, but without success. The solution I found was create a view with the calculated average and include a new group of measures.
In my cube there are certain measures which are non-additive, however I can compute a value for every drill down level. Unfortunately the computation is too complex for it to be done in in Analysis Services.
If I precompute the drill down levels I'm interested in, I have to put those values into a separate fact-table / measure group for each drill down level, or don't I? Is it possible to do this in a way that is transparent to the end user? So it should look like there is only one fact table and SSAS automatically selects the value from the correct fact table based on the drill-down level?
I found the answer in a Microsoft forum: http://social.msdn.microsoft.com/Forums/en-US/sqlanalysisservices/thread/d5998b23-936b-4e7b-b593-bd164b20c022
On the Calculate tab you can define a scope statement:
In this really trivial example, internet sales amount will be shown when reseller sales amount is chosen (at calendar quarters).
scope([Measures].[Reseller Sales Amount], [Date].[Calendar].[Calendar Quarter]);
this=[Measures].[Internet Sales Amount];
end scope;