简体   繁体   中英

I want YTD amount for each category in my MDX query

I've one MDX query where i want to show each of my product month wise count and along with that want to show YTD, MTD, WTD etc.

I've first created following MDx query on Adventure Works which give me YTD but its shows each months. instead i need output as below and I want to provide current month+year(Mar 2015) in MDX filter or where clause

EXPECTED Results:

Category    YTD 
---------   ------
Bike        4500
Accessories 78000
Clothing     8900

Can you please correct below MDX query to get above results sets

SELECT
    {
    ([Product].[Category].CHILDREN,[Measures].[Order Quantity])
    } ON 0,

    {
    YTD([Date].[Calendar].[Month].[August 2008])
    } ON 1
FROM [Adventure Works];

or i've built another MDX query which give same results either one should be corrected to show above EXPECTED results.

SELECT
    {
    ([Product].[Category].CHILDREN ,[Measures].[Order Quantity])
    } ON Axis(0),

    {
    PERIODSTODATE([Date].[Calendar].[Calendar Year],[Date].[Calendar].[Month].[August 2008])
    } ON Axis (1)
FROM [Adventure Works];

I don't think I have the same version of the AW cube as you (or what version of SSAS you are using), but try this. In the 2014 multidimensional cube, I have to change the measure to Order Count rather than quantity and change the date to March 2012 to get data back.

WITH MEMBER [Date].[Calendar].[CalendarYTD] AS
    Aggregate(
        YTD([Date].[Calendar].[Month].[March 2015])
    )
SELECT 
    [Date].[Calendar].[CalendarYTD] ON COLUMNS,
    [Product].[Category].Children ON ROWS
FROM
    [Adventure Works]
WHERE
    [Measures].[Order Quantity]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM