Hi I have created a time dimension like below:
Here i am considering the 4 Weeks as one Quad (In a year we will get total 13 Quads)
, I Need to use the Quad in MDX Paralle period function, When i select the current quad it needs to take the last year same quad and needs to dispaly the data.
The Dimesion like below:
To Achive the same i have used the quad in MDX and passed the int value as 13, but not worked for me.
As Per #FrankPI
I wrote the MDX Query like below:
with member [Measures].[pycomp]
as
ParallelPeriod ([DimTime].[Time].[Year], 1, [DimTime].[Time].[Quad].CurrentMember)
select [Measures].[pycomp] on 0,
[DimTime].[Time].[Year].&[2012].&[Quad 07 (2012)] on 1
from [Cube]
I am getting the error as i said in the below comments "#Error".
When i click on the cell it showint the below msg.
CellOrdinal : 0
VALUE : #Error Query (3, 45) The CURRENTMEMBER function expects a hierarchy expression for the 1 argument. A member expression was used.
FORMATTED_VALUE : #Error Query (3, 45) The CURRENTMEMBER function expects a hierarchy expression for the 1 argument. A member expression was used.
Any help is apprecieated.
Thanks,
Roshan
ParallelPeriod ([Date].[Calendar].[Year], 1, [Date].[Calendar].CurrentMember)
should deliver you the quad one year before the current one. The first argument is the level to use as the reference (year in this case), the second the number of reference periods (in this case years) to go back, and the third argument is the reference point, normally on a lower level than the reference level.
Edit
According to your edited query, and assuming you did not rename DimTime in the cube object, this should be as follows:
ParallelPeriod ([DimTime].[Time].[Year], 1, [DimTime].[Time].CurrentMember)
Related
I have this problem to find a generic MDX expression that returns the percent of grand total regardless of the dimension that i drag in the SSAS cube browser.
Now i'm using this expression:
([Measures].[Montant], Axis(1)(0)(Axis(1)(0).Count - 1).dimension.currentmember)
/SUM(([Measures].[Montant], Axis(1)(0)))
it works fine, but when i filter on the inner item of the axis, the expression returns a wrong value
For example :
i have in my rows axis 3 items : Year > Brand > Category
The grand total is 125 for all rows:
SUM(([Measures].[Montant], Axis(1)(0)))
If i filter on the categories , the grand total changes, lets say it is equal to 65 now for the outer items of the axis. But when i drill down to see its value for the categories, i find it still equal to 125. and as a result the value of percent is wrong as well.
Can someone please help me figure out what's wrong with my MDX expression coz i've been stuck at it for too long and i don't seem to find a solution.
screenshot of cube browser
The calculated measure is "test SOB", MDX expression :
([Measures].[Montant], Axis(1)(0)(Axis(1)(0).Count - 1).dimension.currentmember)
/SUM(([Measures].[Montant], Axis(1)(0)))
the grand total is "denominateur", MDX expression:
SUM(([Measures].[Montant], Axis(1)(0)))
as you can see, the value after filtering with Onglet = "DIGITAL" is 182.50 but when I drill down the brand "Beauty" to see "denominateur" per category, i find the value 338.05 which is the value of "denominateur" before applying the filter.
I'm wondering if the use of EXISTING will enforce the filter context in your denominteur calculation?
SUM(
[Measures].[Montant],
EXISTING Axis(1).ITEM(0).ITEM(0).HIERARCHY.MEMBERS
)
I am trying to create a calculated measure that finds the difference between two measures by using the following mdx query
WITH MEMBER [Measures].[Available]
AS ([Measures].[Capacity days] ,[Project].[Projects by Name].[All],[Project].[Projects by Code].[All])
- ([Measures].[Worked Days] ,EXCEPT([Project].[Projects by Name].[Project].MEMBERS,
[Project].[Projects by Name].[Project].&[1214]),[Version].[Version].[Combined],[Charge].[Charge].[All])
In case of second measure Worked Days I want to access it with respect to all projects except one ,so am using EXCEPT function which results in the following error
" The function expects a string or numeric expression for the argument. A tuple set expression was used"
Is there any other way to perform this operation?
The query is mixing tuples with sets. Perhaps you can check this gentle introduction of MDX for main concepts and notations.
The second tuple is using a set (the result of EXCEPT) as its second member which is not possible. You could use the aggregate function as following to compute the [Worked Days] over the members of this set instead :
AS ( [Measures].[Capacity days], ... )
- Aggregate(
Except (
[Project].[Projects by Name].[Project].MEMBERS,
[Project].[Projects by Name].[Project].&[1214]
),
( [Measures].[Worked Days], ... )
)
I have a requirement where in i am to extract data from a cube, within the SSRS dataset using the query builder ,with the time dimension in the result set, across a range of dates. The conditions are
The measures are to be displayed for each day of the date range.
The sub total row should have the last available measures value for that time range.
There is a time filter (currently a single date filter with a multi select option).
my MDX is as below.
The measure has a 'Sum' as the aggregation type.
I have a calculated measure with the scope defined as below.
SCOPE([MEASURES].[Measure1]);
SCOPE([Date].[Date].MEMBERS);
THIS = TAIL(EXISTING ([Date].[Date].MEMBERS),1).ITEM(0) ;
END SCOPE;
END SCOPE;
This above scope statement works perfectly. however, when i select in more that one date member this query slows WAYYYYYYY down. Performance numbers are
Across 1 date - 4 seconds
Across 2 dates - 22 minutes
Across 3 dates - unknown (in Hours)
This drastic degradation in performance goes away if i remove the scope statement, which makes me thing that there should be a better way to do the same. the final report query is as below.
SELECT
NON EMPTY
{[Measures].[Measure1]} ON COLUMNS
,NON EMPTY
{ [Dimension1].[Dimension1].[Dimension1].ALLMEMBERS*
[Dimension2].[Dimension2].[Dimension2].ALLMEMBERS*
[Dimension3].[Dimension3].[Dimension3].ALLMEMBERS*
[Date].[Date].[Date].ALLMEMBERS
} ON ROWS
FROM (
SELECT {[Date].[Date].&[2014-06-13T00:00:00]
,[Date].[Date].&[2014-06-16T00:00:00] } ON COLUMNS
FROM [Cube]
)
So the question again is, Is there a way to do the last available value part of the scope statement so as to have a better performance? Also, if there is another way to write the final mdx that would help the performance?.
Please let me know if there are anythings unclear regarding the question.
Thanks
Srikanth
The first optimization step would be to change your query to
SELECT
NON EMPTY
{[Measures].[Measure1]} ON COLUMNS
,NON EMPTY
{ [Dimension1].[Dimension1].[Dimension1].ALLMEMBERS*
[Dimension2].[Dimension2].[Dimension2].ALLMEMBERS*
[Dimension3].[Dimension3].[Dimension3].ALLMEMBERS*
{[Date].[Date].&[2014-06-13T00:00:00], [Date].[Date].&[2014-06-16T00:00:00] }
} ON ROWS
FROM [Cube]
Furthermore, I am not sure why you added the SCOPE([Date].[Date].MEMEBER); (probably Date].[Date].MEMBERS, actually). Maybe it helps to omit it and the corresponding END SCOPE.
i have a huge table of cashflows that means there are +int values for income and -int values for outcome.
I have MeasureGroup for Sum the amount of money.
I now want to display not only the sum of money per month but also the sum of all the past time until the current month so like that:
Month MoneyAmount Total
1 20 20
2 -10 10
3 5 15
4 -10 5
So i know for the first part its just like
select [Measures].[Money] on 0,
[Date].[Month].Members on 1
From MyCube
but how can i add the sum column?
i thought about something like SUM( { NULL : [Date].[Month].CurrentMember } , [Measures].[Money] ) but that didnt work as well :(
In MDX, the total is already there. You do not have to do complex calculations to get it.
But it depends on your exact hierarchy structure how the All member is called. If you have a date user hierarchy named [Date].[Date], and it has a month level named [Date].[Date].[Month], then the all member of the hierarchy would probably be called something like [Date].[Date].[All]. If [Month] is an attribute hierarchy of the Date dimension, then the "all member" would probably be called [Date].[Month].[All]. In the latter case, the all member would already be the first member of the set [Date].[Month].Members. As you are asking the question, I am assuming this is not the case, and you are using a user hierarchy. Then you could change your MDX query to
select [Measures].[Money] on 0,
Union([Date].[Month].Members, { [Date].[Date].[All] }) on 1
From MyCube
Please note that you can change the name of the All member in the property settings of a dimension when designing an Analysis Services dimension, hence I cannot know the definitive name without knowing the details of this setting in your cube. So you might have to adapt the name of the all member.
You can find this name out in SQL Server Management Studio in an MDX window as follows: open the hierarchy that you are using, and then open the "Members" node, below which you should find the "All Member". You can drag this into your MDX statement, and the proper name will appear there.
As in a running sum?
You need a calculated measure, like this:
With Member [Measures].[Running Sum] as Sum( ( [Date].[Months].Members.Item(0) : [Date].[Months].CurrentMember ), [Measures].[Money])
Select [Date].[Months].Members on Rows,
{[Measures].[Money], [Measures].[Running Sum] } on Columns
From [MyCube]
I don't understand how to use LinRegPoint MDX function to show actual and estimated values of measures.
I have a MDX query that returns vales of two measures for each dimension member e.g:
WITH SET Product AS ...
SELECT
{[Measures].Size, [Measures].Cost } on 0,
Product on 1
FROM MyCube
This works fine and returns me size and cost on columns and repeat values for all products in separate rows. I want to apply linear regression in order to see what would be predicted value of cost based on size and calculate error. I don't need any prediction so I'm using the current values.
How can I include estimated cost column using LinRegPoint method? Looking at the article (http://technet.microsoft.com/en-us/library/ms144752.aspx) I tried something like:
WITH SET Product AS ...
SELECT
{[Measures].Size, [Measures].Cost
, LinRegPoint([Measures].Size, Products, [Measures].Size, [Measures].Cost)
} on 0,
Product on 1
FROM MyCube
However, it return an error:
The function expects a tuple set expression for the 3 argument. A string or numeric expression was used.
According to the http://technet.microsoft.com/en-us/library/ms144752.aspx thrd argument should be numeric expression Numeric_Expression_y so what is wrong here?
The only difference was that I have not used some period (e.g. Last(10) as in MSDN) because I want to apply regression across all products.
I don't find the MSDN useful for this so could someone explain me how LinRegPoint should be used using this simple example?
I guess the issue is not with the argument of the LinRegPoint MDX function but with LinRegPoint call; LinRegPoint returns a numerical value that cannot be added to the axis set :
WITH
SET Product AS ...
MEMBER LRP as LinRegPoint([Measures].Size, Products, [Measures].Size, [Measures].Cost)
SELECT
{ [Measures].Size, [Measures].Cost, LRP } on 0,
Product on 1
FROM MyCube