We have an OLAP cube with the following dimensions: Ship_Date, Product, Customer. The measures are Units, Cost, List Price, Sell Price.
We want to set up calculations of Cost/Unit, List Price/Unit and Sell Price, like the below:
[Measure].[Cost]/[Measure].[Units]
This works with one time elements (All Ship Dates, 2016, Jan 2016, etc.) but when multiple elements are selected, like 2016 & 2015 or Jan 2016 & Feb 2016, the calculation does not resolve correctly which we think is because it is summing the ratios instead of calculating against the sums.
I tried the below calculations to similar results:
SUM([Ship_Date].CurrentMember.Level.Members,[Measure].[Cost]) /
SUM([Ship_Date].CurrentMember.Level.Members,[Measure].[Units])
SUM(Descendants([Ship_Date].CurrentMember, [Month]), [Measure].[Cost]) /
SUM(Descendants([Ship_Date].CurrentMember, [Month]), [Measure].[Units])
Aggregate(Descendants([Ship_Date].CurrentMember, [Date]), [Measure].[Cost]) /
Aggregate(Descendants([Ship_Date].CurrentMember, [Date]), [Measure].[Units])
I'm very new to MDX - can someone please point me in the right direction?
Maybe try playing with the calculation's solve_order: https://msdn.microsoft.com/en-us/library/ms145539.aspx
DIVIDE(
[Measure].[Cost]
,[Measure].[Units]
)
, SOLVE_ORDER = 1 //<<also maybe try -1 or -6500
Related
Revenue month chart of 2011
I am supposed to make line chart to analyse the revenue for each month in a particular year. So what should be done other than this? Is this one right?
The Revenue column is the problem. I believe you want a continuous measure (Sum, Max, Avg etc) while you are now using a continuous dimension.
Remove the Revenue from rows and bring a Sum(Revenue) or similar.
Wrong chart type, and (perhaps) data aggregation issue - you want a bar chart by month, not a line-chart by day.
I am using SSAS Multidimensional cube.I have factsales and two dimdate,dimsalespoint table. I need to show top sales every month by sales point.Also i need to show this data into power bi.My cube brower will be look like
July salespoint1 1254
Aug Salespoint2 2589
Sep SalesPoint3 85236.
Per month which sales point sales high.
It will also filter year, product etc.
Can any one help me.
I think that you can do this with only PowerBI
You juste need to drag you sales infos and select max aggreagate and filter them by month and salespoint.
In powerBI you connect to your cube
you drag and drop your salesvalue and select the matrix visual
you use salespoint in row , date in column and salesvalue in values
You can select a max aggregate on your values
You'll get something like this :
and you can navigate in the date hierarchy by using the arrow on the top right
If you use a live connexion with an OLAP cube.
You can replace you max in powerBI by doing these step :
and select max
you then have to use this measure in the powerBI report because it will be based on your table filtered by what you put in the visual(date, salespoint,...)
Let's assume i have easy table with sales data like:
id shop
id product
date
amount
Can you help me to write MDX query for calculated member to get current period sales ratio to same period of previous year?
For example, if month or quarter selected as one of dimensions.
Let's assume you've a [Time] dimension with [Year], [Month] and [Day] levels.
If
SELECT
[Time].[Jan 2015]:[Time].[Dec 2015] on 0,
[Measures].[Sales] on 1
FROM
[Cube]
Returns the sales for all months of 2015. We can add a calculated measure to get ratio :
WITH
MEMBER [Sales Ratio] AS DivN(
[Sales],
( ParallelPeriod( [Time].[Year], 1, [Time].current ), [Sales] )
SELECT
[Time].[Jan 2015]:[Time].[Dec 2015] on 0,
{[Sales],[Sales Ratio]} on 1
FROM
[Cube]
DivN is icCube specific and allows for dividing being 'empty' safe.
ParallelPeriod is a standard MDX function, that returns previous years month. You could also use Lag(-12), that is 'travelling' backwards in a level 12 times.
current (aka Currentmember) is also standard MDX and allows for retrieving the current value of a hierarchy/ dimension.
In icCube I'd add a function to navigate to the previous year so you can reuse it (and fix one if needed). Like :
WITH
FUNCTION timePrevYear(t_) AS ParallelPeriod( [Time].[Year], 1, t_ )
MEMBER [Sales Ratio] AS DivN(
[Sales],
( timePrevYear( [Time].current ), [Sales] )
SELECT
[Time].[Jan 2015]:[Time].[Dec 2015] on 0,
{[Sales],[Sales Ratio]} on 1
FROM
[Cube]
It's going to be a bit too much but eventually you could add this kind of calculations in what we call in MDX Utility or Stats dimension, so you can even let the end-user select this in a dropdown from a reporting tools. More on this here.
In the models I create for my clients, I sometimes take another route as ic3 has suggested:
Especially when there will be lots of additional calculations on top of these (e.g. year-to-date, inception-to-date, month-to-date etc).
This is:
load the same facts data again, but set as the "load date" the "date" - 1 year (e.g. mySQL: DATE_ADD(,INTERVAL -1 YEAR).
Advantages:
drill through on history is possible
lots of formulas can be added "on top" of these, you always know that the basics are ok
I have a cube in my sql server analysis service (2012) project. One of my measures is withdrawn money from ATM. Now I want to have a new calculated measure that show me the growth of withdrawn money today toward to last day. It is a dynamic calculated measure.
Is there any solution for doing this work?
What you are looking for is most probably called a KPI = key performance indicator. Look here for information about how to add the metric you need.
if you want to show growth based on last value, for example today I Withdrew 10% less than yesterday, yo ucan use KIPs
if you want to show how much you Withdrew so far, you should use calculatins like YTD (year to date)
You should use KPI to build your measure.
Open your SSAS project in Visual Studio and double click on your cube.
In the KPI tab there is a panel with some samples of KPI using parallel periods.
This is an example to create an operating margin accross two periods :
IIf
(
KPIValue( "Gross Profit Margin" ) >
( KPIValue( "Gross Profit Margin" ),
ParallelPeriod
(
[<<Time Dimension Name>>].[<<Time Hierarchy Name>>].[<<Time Year Level Name>>],
1,
[<<Time Dimension Name>>].[<<Time Hierarchy Name>>].CurrentMember
)
), 1, -1
)
I have a query:
select non empty
order ([Item].Children
,([Measures].[Total Line Value]
,[January 2010])
,DESC)
on Columns,
non empty
[January 2010]
on Rows
from [Sales Analysis]
where [Measures].[Total Line Value]
This query shows, in order from highest to lowest, the total sales a particular item has made for the month January 2010. What I would like to do is show the total sales an item has made between 2 specified dates, say January 2010 - March 2011. It just has to be the total value and not the value for each month. Any help would be appreciated, thanks.
Use "WITH" statement to declare new measure
Sum({[Your dim-n].[January 2010]:[Your dim-n].[March 2011]}, [Measures].[Total Line Value])
Use this new measure on the axis Rows and remove WHERE clause.
p.s. I can't test it now, so I can make a mistake :).