| MDX-How do I calculate sales for 12 Month to date? |
| Written by Vidas Matelis | |||||||||||||||||||||||||||||||
| Friday, 08 June 2007 02:44 | |||||||||||||||||||||||||||||||
|
Q: How do I calculate sales for 12 Month to date in MDX? A: We have to assume that your date dimension last member represents last month. Then to get last 12 month we can use Lag function. Example: SELECT [Measures].[Order Count] ON 0 Result:
Now to get sum of sales query could be :
Result
|
Most read
- How to install Adventure Works SQL DW and Analysis Services 2005/2008 sample database and project
- MDX-How can I get Last (Previous) Year to Date (YTD) values?
- Analysis Services 2005 error: Errors in the metadata manager. The attribute with ID of ., Name of . refer
- MDX-How do you format or round KPI expression value?
- MDX-How do you calculate monthly average of one year, optionally including empty months?
Top Rated
- How to install Adventure Works SQL DW and Analysis Services 2005/2008 sample database and project
- Analysis Services 2005 XMLA script to add/drop existing partition aggregate
- Why In Reporting Services MDX query disappears after leaving "Data" tab.
- When accessing calculation tab in BIDS I am getting error Unexpected error occurred
- In an MDX query how can I get the top 3 sales years based on the order quantity?
- What TCP port SQL Server Analysis Services 2005 uses
- How to calculate YTD monthly average and compare it over several years for the same selected month
- Analysis Services 2005 error: Errors in the metadata manager. The attribute with ID of ., Name of . refer





PeriodsToDate(
[Date].[Calendar].[Year],
[Date].[Calendar].[Year].[@Year]
),
[Measures].[Sales Amount])
I defined the parameter in dataset whose value i set to the report parameter, It is not working Above is what i modified when i defined parameter. Can any body help me plz how to parameterized year in above code?
Thanks
Aggregate(
PeriodsToDate(
[Date].[Calendar].[Year],
[Date].[Calendar].[Year].[Year 2007]
),
[Measures].[YourMeasure])
I used this code to calculate the YTD Measure using Add Calculated tool, It worked fine but when i used it in report using expression just like other Field values, It gives me Output in "xml" kinda form instead of Values. In query pane it works fine. Any body have Idea how i will use this calculated Measure in report?
Thanks
Regards
Is there any way that we can use just expressions for this instead of MDX query?
WITH MEMBER [Measures].[Last 12 Mth Order Count] AS
SUM(
ClosingPeriod([Date].[Month].[Month], [Date].[Month].[All]).Lag(12)
: ClosingPeriod([Date].[Month].[Month], [Date].[Month].[All])
, [Measures].[YourMeasure]
)
SELECT [Measures].[Last 12 Mth Order Count] ON 0
FROM [Your Cube]