MDX - Calculations of Daily Stock (Financial Instrument) Values - ssas

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.

Related

Setting up GST invoice application report differs for item wise sales against total sales

We have set up GST application where I am getting difference between reports like monthly item wise sales report against monthly total sales report.
Please suggest me any changes I need to make for following rules:
We have 3 tables
A. Order master - single line for every order is stored with summarized values
B. Order product details - Each line item stored with respective qty, price etc.
C. Order tax details - line item wise tax details having separate row for CGST, SGST etc.
Here is how I am storing the data:
Tax is applicable on every line item [To generate final invoice all items in order group, we create some of all line items and storing value in Order Master.]
We are rounding 2 decimal value for 3 precision [eg. 4.657 = 4.66, 4.643 = 4.64] as per GST council
Rounding value is stored in Order Master table
For discount there are 2 cases
Percent based discount - Let's say if discount is 10% then from every individual line item 10% discount gets deducted than tax will be applicable for each line item
Flat discount - Let's say for 1000/- Rs order somebody wants to give 80/- Rs. discount than from each line item 8% is deducted and than tax will be applied, off course customer may not pay exact 920/- Rs. amount due to reversal of tax amount.
Now when I am generating following reports:
Monthly item wise sales report [Product wise sales report]
Monthly total sales report [Total sales]
Monthly payment type wise report [Bank, Cheque, Cash]
I am getting difference due to rounding of values. Can anyone suggest me which is the best way to set up rounding formula and up to which decimal point should I go to round the values.
I am using SQL server as backend and .net as front end technology.

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

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.

Summing of averages

SSAS 2012, AdventureWorks Tabular Model SQL 2012
Having a hierarchy of some fields, want to list values from a measure per month in a year, then see average value for month, then sum these averages on all hierarchy levels up.
Example: (all measures in table 'Internet Sales')
ComplexCalculation:=[Internet Total Sales]*[UnitPriceAvg]/1000
UnitPriceAvg:=AVERAGE('Internet Sales'[Unit Price])
AvgComplexCalculation:=AVERAGEX(VALUES('Date'[Month]), [ComplexCalculation])
AverageAndSumComplexCalculation:=IF( ISFILTERED(Product[Product Name]), [AvgComplexCalculation], SUMX (VALUES (Product[Product Name]), [AvgComplexCalculation]))
Pivot Fields:
Filters: [Calendar Year] [2006]
Rows: [Product Category Name],[Product SubCategory Name],[Model Name],[Product Name],[Month]
Columns:
Values: [AverageAndSumComplexCalculation]
Is it the right way of doing this? Noticed that when my "ComplexCalculation" measure becomes more and more complex it needs lot of time to calculate the values (causes timeout).

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 Calculating 12 month average unit price and applying to forecast quantity

I have a requirement to show a report which calculates the average selling unit price of each product and then multiplies this average by the number of units forecasted to sell in the next year (for each product).
At this point my main issue is getting this set up so the totals roll up correctly when viewing at product category level. Using AdventureWorks as an example (and sales orders instead of forecasts) I've got this far...
with
member [Measures].[Sales Order Value]
as sum(descendants([Product].[Product Categories].currentMember,
[Product].[Product Categories].[Product]),
[Measures].[Average Unit Price] * [Measures].[Order Count]),
format_string = "Currency"
select ([Date].[Calendar].[Calendar Year].&[2008],
{[Measures].[Sales Order Value] }) on columns,
[Product].[Product Categories].[Subcategory].members on rows
from [Adventure Works]
I think this is about right, I believe this is going down to product level to apply the calculation between product average unit price and any sales orders for the product.
My issue is that I think the average unit price is being calculated over all data, I need to alter this to pick up an average based on the last 12 months only.