Environment: SQL-Server-2005, SSAS 2005
I am using the following formula to create a Moving Annual Total
SUM ({[Time].CurrentMember.Lag(3):[Time].CurrentMember}, [Measures].[TRx Quantity])
The same column [Measures].[Trx Quantity] is used in other calculations and it works fine. This one, however, comes up with #Value! to indicate some kind of an error. Can anyone point me in the proper direction here?
Is this SSAS 2005/2008?
If it is either of these and you are running this in Management Studio you can hover over the #Value and get the details of the error.
But at a guess it is most likely because .CurrentMember needs to be called on a hierarchy and [Time] is a dimension reference. It should refer to one of the hierarchies like [Time].[Calendar].CurrentMember or maybe [Time].[Quarter].CurrentMember
It turned out to be that I was missing the MONTH
SUM ({[Time].[Month].CurrentMember.Lag(3):[Time].[Month].CurrentMember}, [Measures].[TRx Quantity])
Related
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 have a cube in SSAS multidimensional mode.
I have created a calculating measure in visual studio called "Total Cost". The formula is:
[Measures].[Unit Cost]*[Measures].[Qty]
It is in the lowest level of granularity (i.e. - the transnational level information has these fields).
The formula works well, as long as I present the data in this same level of granularity (for example, when I create a pivot and the rows are transaction IDs - like the source file)
However, when I present it in an aggregate format (for example - by customer) - then instead of making the calculation and then sum it up, it sum up and then calculate.
Here is what I expected:
Expected results vs. What I get
My understanding, that this is regardless a (correct/incorrect) hierarchy structure. In other words, I expected this calculation to work even without defining any hierarchy between the transaction ID level and the customer level.
I'd appreciate your help!
In your SSAS project ->datasource view, you need to add a named calculation. This would be "[Unit Cost]*[Qty]". Now add this named calculation as a Measure in your Cube. This do the job. This problem was already addressed in the following link.
https://stackoverflow.com/questions/53554284/how-to-multiply-two-measures-prior-to-aggregation/53558733#53558733
I am using Analysis Services on SQL server 2014, enterprise edition.
I am trying to create a new member for Timeframe dimension that aggregates last 3 months values. The following mdx code gets compiled without errors, but when I browse it with a measure, it still shows me the month level numbers, instead of last three month sum. What am I doing wrong? Any help is appreciated.
CREATE MEMBER CURRENTCUBE.[Timeframe].[Timeframe].[ROLLING 3 MONTH]
AS IIF([Accounting Date].[Accounting Date].CurrentMember.Level.Name="Month", AGGREGATE(LASTPERIODS(3),[Timeframe].[Timeframe].&[1]), NULL),
VISIBLE = 1;
Thanks.
Please try the following:
CREATE MEMBER CURRENTCUBE.[Timeframe].[Timeframe].[ROLLING 3 MONTH]
AS
IIF(
[Accounting Date].[Accounting Date].CurrentMember.Level.Name="Month",
AGGREGATE(
LASTPERIODS(3, [Accounting Date].[Accounting Date].CurrentMember),
[Timeframe].[Timeframe].&[1]
),
NULL),
VISIBLE = 1;
Specifying the member in the LASTPERIODS function is hopefully what you were missing. SSAS was probably assuming some other Date hierarchy or you don't have any hierarchies and dimensions properly marked. That's ok. Just specify the member and then it should work.
By the way, for performance reasons I would prefer to see a SCOPE statement instead of checking the level's name. What you have should work but if you hit performance issues research SCOPE statements or create a new thread asking to optimize that MDX.
I assume you are using Excel 2010 or higher. If not watch out!
I'm still new to MDX and I'm trying to get some basic functions to work in my SSAS cube. Can you guys point out what I'm doing wrong here? I've added a calculated measure to my cube with the following code:
CREATE MEMBER CURRENTCUBE.[Measures].[Amount YTD]
AS
AGGREGATE(
YTD([OrderDate].[Calendar].CurrentMember)
,[Measures].[Amount]),
VISIBLE = 1, ASSOCIATED_MEASURE_GROUP = 'MyMeasureGroup';
After that I'm trying to get some data going...
SELECT
NON EMPTY
{
[Measures].[Amount]
, [Measures].[Amount YTD]
} ON COLUMNS,
NON EMPTY
{
[OrderDate].[Month].ALLMEMBERS *
[Product].[Product Group].ALLMEMBERS
} ON ROWS
FROM (SELECT ([OrderDate].[Year].&[2014-01-01T00:00:00]:
[OrderDate].[Year].&[2015-01-01T00:00:00]) ON COLUMNS
FROM [SalesOrderIntake])
This is the output I'm getting:
I'm not seeing any errors in my Output messages, which makes it difficult for me to figure out what is acting up. Hoping you guys can help me out on this one.
FYI: the actual select is just for testing purposes. I just want to get that YTD running. I've tried several things and it always comes out empty, so I was hoping to get some actual errors if I would query it directly in SSMS instead of using a BI tool. Also, the OrderDate dimension is a generated Time dimension which was provided to me by VS.
In your query you're using what looks like an attribute hierarchy:
[OrderDate].[Month].ALLMEMBERS
Whereas the measure uses the user hierarchy:
[OrderDate].[Calendar]
If you use Calendar in your script does it work ok?
#Error usually crops up when there are run time errors in MDX code. I could think of one scenario where the error might crop up. You are using [OrderDate].[Calendar].CurrentMember in the calculated member. But if instead of one, there are multiple members from this hierarchy in scope, it will throw an error.
The below is a scenario from Adventure Works.
with member abc as
sum(YTD([Date].[Calendar].currentmember), [Measures].[Internet Sales Amount])
select abc on 0
from [Adventure Works]
where {[Date].[Calendar].[Date].&[20060115], [Date].[Calendar].[Date].&[20060315]}
P.S. Thanks to #whytheq for teaching me this trick of checking this error by double clicking the cell :) Cheers.
I know, its an old post, but in the interest of posterity..
The correct approach is :
Aggregate
(
PeriodsToDate
(
[OrderDate].[Calendar].[Fiscal Year]
,[OrderDate].[Calendar].CurrentMember
)
,[Measures].[Amount]
)
I a new to this site and to SSAS in general. I am currently doing some "on the job training" trying to put together an SSAS cube and I am experiencing some problems.
When I try to process the Cube it fails. This happens due to the fact that the Fact table used for the cube contains some 13 rows that have dates that are outside of the range of the Date dimension that I am using.
I am not sure what I should do to get around/fix this.
Exclude the rows?
Change the dimension?
I have tried to find an answer to this on my own, but it seems that my phrasing of the issue/problem has so far stopped me from finding relevant information.
Any advice or ideas would be greatly appreciated!
/Chriss