SSAS Grand Total for calculated measure in excel not working - sql

I have an ssas cube with a calculated member called cumulative ptp's.
Everything seems to work in excel except for the Grand Total which is displaying #Value!. I'm not sure where the problem is. I've added a few pics of what I have done. Any help will be most appreciated. Thanks in advance.
IIF
(
[Day-Month Analysis].[Day].FIRSTCHILD = [Day-Month Analysis]. [Day].CURRENTMEMBER,
Sum(
{[Day-Month Analysis].[Day].FIRSTCHILD:[Day-Month Analysis]. [Day].CURRENTMEMBER},
[Measures].[Sum of IsPTP]
)
, SUM(Measures.[Sum of IsPTP])
)
So I downloaded that extension and the MDX error is:
"Range operator (:) operands' have different levels; they must be the same"

Try this:
Sum(
{[Null:[Day-Month Analysis].[Day].CURRENTMEMBER},
[Measures].[Sum of IsPTP]
)
I don't think you need the IIf. If that doesn't work right describe what's in that [Day] hierarchy further.

Related

How to use Median function in MDX?

I have a SQL Server Analysis Services cube ( Multidimensional). This cube represents Survey feedback. A student gives feedback on course for a given term (period of time ). There are 19 questions with a score from 1 to 5 and I try to get the median of these answers.
Just to precise, I am looking at the median of answer for each {Question, Course} just for one period of time ( term).
My cube model looks like this :
And the query I am running is :
with calculated member [Median] as
MEDIAN(existing NONEMPTY([Course].[COURSE NAME].children*[Survey
Question].[SURVEY QUESTION NUMBER].children),[Measures].[NUMERIC
RESPONSE])
Select non EMPTY{[Course].[COURSE NAME].children} on rows,
NON EMPTY{[Survey Question].[SURVEY QUESTION NUMBER].children*{[Measures].
[NUMERIC RESPONSE],[Median]}} on columns
from [EDW]
where [Term].[TERM].&[5515]
The result doesn't show anything on the Median as if it was null.
If anyone has an idea around this issue I will love to hear it.
Regards
Vincent
This is your query with a couple of small changes - unfortunately not used Median before and I do not have AdvWks to test on so feeling around in the dark a little:
WITH
MEMBER [Measures].[MYMedian] AS
MEDIAN(
NONEMPTY(
[Course].[COURSE NAME].[COURSE NAME].MEMBERS
*[Survey Question].[SURVEY QUESTION NUMBER].[SURVEY QUESTION NUMBER].MEMBERS
,[Measures].[NUMERIC RESPONSE]
)
,[Measures].[NUMERIC RESPONSE]
)
SELECT
NON EMPTY
[Course].[COURSE NAME].children on rows,
NON EMPTY
[Survey Question].[SURVEY QUESTION NUMBER].children
*{
[Measures].[NUMERIC RESPONSE]
,[Measures].[MYMedian]
}
on columns
FROM [EDW]
WHERE [Term].[TERM].&[5515];

MDX Calculation . Filetring a measure based on the value in another column

I see the problems I have are of nature 'filter one fact table measure based on the value of a column in the same fact table'.
I have a cube with measure called Report. ‘Calls’ and ‘Failure’ are columns of this measure. There is a dimension called ‘trial’. I have to write few new calculations in SSAS Cube.
Sum([measure].[calls] ) only if failure = 1 and value of [Trial categories].[Trail].&[1].
 I din’t get the desired result using filter. So I created a new column in the fact table ‘calls_if_failure’ = ‘calls’ or 0 depending on the value of failure column.
 And then in the calculated column I used sum([calls_if_failure], [Trial categories].[Trail].&[1]) . Is this the only way to do this?
Now I have many more requirements of the nature ->
Sum([measure].[calls] ) only if [measure].[visit] = 1
Should I take the same approach as before to arrive at the solution? If yes, then this would mean many more columns in fact table.
Appreciate any help. Thank You.
Struggling to understand the question a little but maybe the following will at least help to give you some ideas:
SUM (
IIF (
[Trial categories].CURRENTMEMBER IS [Trial categories].[Trail].&[1]
 , [measure].[calls]
 , NULL
)
)

How to get current row value in a WITH MEMBER calculation MDX?

I would like to calculate a Measure based on the current row.
Problem is I can't find a way to get the current row in a WITH MEMBER part.
WITH MEMBER [Measures].[Test] AS AVG(
NonEmptyCrossJoin(
FILTER(DESCENDANTS([Exigences].[ENVGR], [Levier], SELF),
[Exigences].CurrentMember.Name = 'Chemicals'),
DESCENDANTS([Organization].[Valeo].[Powertrain Systems], [entity], SELF)),
[Measures].[ProgressLevel])
SELECT {[Measures].[ProgressLevel], [Measures].[Test]} ON COLUMNS,
DESCENDANTS([Exigences].[ENVGR].[ENVGR-01.001], [Levier], SELF) ON
ROWS FROM [Exigences]
Chemicals is currently hard coded. That is for the example.
I would like in place of 'Chemicals' to have the current rows value.
So let's say those are the values rows will return 'Chemicals', 'Pharmacy', 'Test', I would like the [Measures].[Test] calculation to change.
Can MDX do that ? If so how can I get the current value.
I tried [Levier].CurrentMember.Name but I think it's conflicting with the [Exigences].CurrentMember.Name.
Any one has an idea ?
Thank you,
This has been taking a bit of effort but that's the advantage to have a nice gold badge. We're using the MDX Generate function and named sets (myCellSet & 2d example in link) :
Not sure this is going to work for your provider but you can try this one :
WITH MEMBER [Measures].[Test] AS AVG(
NonEmptyCrossJoin(
Generate( {[Exigences].CurrentMember} as MyCellSet,
FILTER(DESCENDANTS([Exigences].[ENVGR], [Levier], SELF),
[Exigences].CurrentMember.Name = MyCellSet.CurrentMember.Name)
)
,
DESCENDANTS([Organization].[Valeo].[Powertrain Systems], [entity], SELF)),
[Measures].[ProgressLevel])

Moving Annual Total SSAS

I have a cube and I want to create a MAT column. This column is then expected to show up in the same way as a regular metric would.
How do I create a column that is a Moving Annual Total in SSAS?
A walkthrough / demo would work as well.
Since you haven't really specified anything (MDX or actually in your cube) I will assume you mean in your cube. If i were you I would write a calculated member and then slide it over when browsing or in your reports. It would be something like this
WITH
MEMBER
[Measures].[Rolling Total]
AS
'SUM ( { [Time].CurrentMember.Lag(3) : [Time].CurrentMember },
[Measures].[Warehouse Sales])'
Then you could do something like this:
SELECT
CrossJoin({ [Time].[Quarter].Members },{[Measures].[Warehouse Sales],
[Measures].[Rolling Total]}) ON COLUMNS,
{[Warehouse].[All Warehouses].[USA].Children} ON ROWS
FROM
[Warehouse]

MDX Calculating Time Between Events

I have a Cube which draws its data from 4 fact/dim tables.
FactCaseEvents (EventID,CaseID,TimeID)
DimEvents (EventID, EventName)
DimCases (CaseID,StateID,ClientID)
DimTime (TimeID,FullDate)
Events would be: CaseReceived,CaseOpened,CaseClientContacted,CaseClosed
DimTime holds an entry for every hour.
I would like to write an MDX statement that will get me 2 columns: "CaseRecievedToCaseOpenedOver5" and "CaseClientContactedToCaseClosedOver5"
CaseRecievedToCaseOpenedOver5 would hold the number of cases that had a time difference over 5 hours for the time between CaseReceived and CaseOpened.
I'm guessing that "CaseRecievedToCaseOpenedOver5" and "CaseClientContactedToCaseClosedOver5" would be calculated members, but I need some help figuring out how to create them.
Thanks in advance.
This looks like a good place to use an accumulating snapshot type fact table and calculate the time it takes to move from one stage of the pipeline to the next in the ETL process.
Query for AdventureWorks (DateDiff works in MDX):
WITH
MEMBER Measures.NumDays AS
'iif(ISEMPTY(([Delivery Date].[Date].CurrentMember
,[Ship Date].[Date].CurrentMember
,Measures.[Order Count]))
,null
, Datediff("d",[Ship Date].[Date].CurrentMember.Name
,[Delivery Date].[Date].CurrentMember.Name))'
SELECT
NON EMPTY {[Ship Date].[Date].&[63]
:[Ship Date].[Date].&[92]} ON COLUMNS,
NON EMPTY {[Delivery Date].[Date].&[63]
:[Delivery Date].[Date].&[92]}
* {[Measures].[NumDays]
, [Measures].[Order Count]} ON ROWS
FROM [Adventure Works]
Taken from: http://www.mombu.com/microsoft/sql-server-olap/t-can-i-have-datediff-in-mdx-265763.html
If you'll be using this member a lot, create it as a calculated member in the cube, on the Calculations tab if I remember right.