SQL Server Performance

Unable to understand the YTD MDX function

Discussion in 'Analysis Services/Data Warehousing' started by Joozh, Dec 5, 2004.

  1. Joozh New Member

    Hi,<br /><br />Me and my thick skull <img src='/community/emoticons/emotion-1.gif' alt=':)' /><br /><br />Couldn't get much help from books on-line and therefore can someone please helpme understand <br /><br />the TYD function with an example maybe?
  2. Raulie New Member

    Mmmm...I've never heard of TYD Function, I know there is a YTD() MDX function.

    Here are some examples. Also a good book I recommend on MDX is MDX Solutionshttp://www.amazon.com/exec/obidos/tg/detail/-/0471400467/102-0888682-9504959?v=glance

    Here is an MDX Query to calculate year to date store sales

    WITH MEMBER Measures.[YTD Store Sales]
    AS
    'SUM({YTD()},[Measures].[Store Sales])'
    SELECT
    {[YTD Store Sales]} ON COLUMNS,
    Time.Month.MEMBERS ON ROWS
    FROM Sales

    To Calculate the average Year to date stock.

    Avg({Ytd()} , ([Measures].[Stock]))

    Here is another example I use but using the PeriodsToDate() function to Calculate Inventory Turns.

    IIF(([Measures].[Total Inv])=0,NULL,
    AVG(PeriodsToDate([Time Inventory].[Fscl Qtr]),[Measures].[Total Usage]*4)/([Measures].[Total Inv], ClosingPeriod([Cal Month]))



    Raulie
    Hewlett-Packard Company
  3. Joozh New Member

    Thanks Raulie (both for the examples and the book recommendation).<br /><br />Honestly at this stage examples appear to be "heavy duty stuff" and that too in some foreignlanguage <img src='/community/emoticons/emotion-1.gif' alt=':)' /> but I hope that one day I will get somewhat comfortable with MDX.<br /><br />Appreciate all thehelp that you have beenextending.<br /><br />Best wishes for the season!

Share This Page