SSAS Calculated Member - how to do percent of total based on another measure - ssas

I am currently trying to create a calculated measure for an SSAS 2008 R2 cube. In a financial cube dealing with accounts receivable data, I have a "Gross Balance" measure, and a "Days Since DOS" measure. The "Days Since DOS" measure is invisible to the user because it is only used in combination with a couple others to gain an average.
I would like the new calculated measure to show the percent of the total gross balance that has a Days Since DOS value > 90.
For example, if the total gross balance were $1000, the total gross balance for records with days since DOS > 90 being $500, the Percent Over 90 Days calculated measure would show 50%.
Would it be possible to do this with my current setup, and if so, how would I go about writing the expression?

I found out that it is in fact possible.
First, create a new named calculation in the DSV using a case statement (for example, call it [Gross Bal Over 90]):
CASE
WHEN [Days Since DOS] > 90 THEN [Gross Balance]
ELSE 0
END
Then, the calculated measure would simply be:
Sum([Gross Bal Over 90])/Sum([Gross Balance])
You can then make [Gross Bal Over 90] invisible to the user, keeping a cleaner look.

Related

MDX - Calculations of Daily Stock (Financial Instrument) Values

How do I calculate the daily values of a Persons Stock (Financial Instrument) using MDX.
A person buys Microsoft Shares/Stock like in the example below. I already have a SSAS MD Cube with this Information (DimDate, DimShare, FactInvestment, DimClient).Fund Units
Can easily calculate the Daily Balance of Units (Unit Balance) using MDX (sum(NULL:[Date].[Calendar].CurrentMember,[Measures].[Units]) to give me daily Balance of Units.[Daily Stock Value][2]
I have a Daily Share price Measure Group with a "Share Price" with Aggregation Usage Last non-empty value. This will give me the daily Stock price.[Daily Stock Price]. The Measure group DOES NOT have a Client dimension.[Daily Stock Price][3]
Would like to calculate the daily value of stock [Unit Balance]*[Share Price] = [Share Values] for each clientDaily Stock Values. See manual calculations in yellow on Pivot Table.

Powerpivot DAX - I need a way to show a value for Revenue in my profit & loss statement even if there is no Revenue

I am having an issue with a consolidated profit and loss statement using calculated fields. There is a column for GL Group, which is either Revenue or Expense. The calculated field asks "if the value of the row is Revenue then flip the sign of the number", and "if it is expense to leave it as is". And for the net income it takes the sum of both and flips the sign to give you a net profit. My issue is that if there is NO revenue then its BLANK and then expenses, which come through naturally as a positive number, remains a positive number on the net income but should rather be a negative. This is what I am looking to achieve: Revenue should be ZERO if its blank, minus expenses, the result of this will always be a negative number (remember the expenses show as positive). Looking to improve this code:
IF(HASONEVALUE(ActualsBudgetsOB[GL_GROUP]),IF(VALUES(ActualsBudgetsOB[GL_GROUP])="Revenue",CALCULATE(SUM(ActualsBudgetsOB[AMT_ACTUAL])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[FISCAL_YR]=[Max Year])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[PERIOD]<=[Max Period]))*-1,CALCULATE(SUM(ActualsBudgetsOB[AMT_ACTUAL])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[FISCAL_YR]=[Max Year])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[PERIOD]<=[Max Period]))),CALCULATE(SUM(ActualsBudgetsOB[AMT_ACTUAL])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[FISCAL_YR]=[Max Year])
,FILTER(ActualsBudgetsOB,ActualsBudgetsOB[PERIOD]<=[Max Period]))*-1)

Count maximum sequel of null values - mdx query

I want to create a member based on this problem
I have a Product A being sold
I want to find the largest range of consecutive days without sale
example:
days 1,2,3 the product not sale, after that,it sold for 15 consecutive days, at 19th day it didnt sell for 2 days and after that it sold every day until the end of the month
so my maximum days without sale was 3
The following query delivers in the Microsoft sample cube Adventure Works what you want:
WITH Member Measures.[days without sales] AS
IIf( [Measures].[Internet Sales Amount] > 0
, 0
,(Measures.[days without sales], [Date].[Calendar].CurrentMember.PrevMember) + 1
)
Member Measures.[Max days without sales] AS
Max( [Date].[Calendar].[Date].Members
,Measures.[days without sales]
)
SELECT { [Measures].[Max days without sales] }
ON COLUMNS
FROM [Adventure Works]
WHERE [Product].[Product].&[486]
The measure days without sales is defined recursively, and returns how many days up to and including the current member of the [Date].[Calendar] hierarchy there was no sales. You may need to adapt the criteria for "without sale", bearing in mind that in MDX, numerical comparisons treat NULL as 0 - which is different from SQL.
This measure only works correctly if there is a member in this hierarchy for each day, i. e. there are no gaps in this hierarchy. And actually, the definition is more general than just working for days: If you use months for the [Date].[Calendar].CurrentMember, it would give you the number of months without sales, etc. It works with each level of the hierarchy.
The measure Max days without sales does not contain the product in its definition, it delivers the maximum days for whatever is in context (in this case the product in the WHERE clause).
Please note that - as actually there is a loop over all days in the [Date].[Calendar] hierarchy when calculating Measures.[Max days without sales], and within that the recursion again iterates along the previous days, and all this for each cell in the result set - this may be slow for large reports.

SSAS MDX Calculated Measure Over Time

I have a calculated measure that needs to cross join Customer and Product dimension then cross join a total sales measure to get a percentage for a specific customer sale.
[Measures].[Sale Value] / [Measures].[Total Sales]
each measure has a link to the time dimension, and are set to last non empty.
The problem is that as I look at more information over longer periods (days, months, years etc) it gets slower and slower and slower. I am assuming this is because the calculated measure does its processing on the fly and there is no caching.
Is this correct? I have about 2000 customers and 50 products.
Please please help! any information about how to speed this up would be great.
The answer to this was to set a many to many relationship between Customer/Prodcut and the [Measures].[Total Sales] measure group.

MDX: How to calculate earned premium (i.e. prorata a measure between two time dimensions)

A simple cube has 1 measure and three time dimensions:
[Measures].[Amount Paid]
[Date Paid]
[Cover Start Date]
[Cover End Date]
Earned Premium =
0% if Cover Start Date is before the period in question
100% if Cover End Date has passed
else [Cover End - Cover Start] * Days Since Start
For any given cell, how do I traverse all the start and end dates and determine what the amount earned for a period is?
I assume other dimension are missing, e.g. one like [ContractId], if no what comes after doesn't make real sense.
The problem here is that your actual measure,earned premium, is a function (Amount Paid, Cover Start Date, Cover End Date, date) and this for each deal. You can not aggregate over a set of deals at once as the function is not associative - or something like this :-).
So I would feed my cube with the premium for each deal over the period [Cover Start Date], [Cover End Date] with the daily premium for this contract. Once you've this you can easily aggregate this measure over your dimensions. -> Now daily premium is not anymore a function of Cover dates..
MDX is not a real calculation engine, so you're pushing the system out of it's limit. Solving this with scopes, calculated measures can produce an amazingly slow cube...