none
Need custom CLR function

    Question

  • Hi !

    I need a CLR function:

    input string as '[Dates].[Year-Month-Date].CURRENTMEMBER.Name'

    and the output is returned as the value of this string, for example - 02.05.2012


    from Moscow with Love

    Monday, June 24, 2013 10:08 AM

Answers

  • Hello ,

      Check the below sample from Adventure works

    WITH MEMBER MEASURES.currentmemberdate
    AS
    cdate([Date].[Date].CURRENTMEMBER.MEMBER_CAPTION)
    MEMBER Measures.RequiredFormat
    AS
    RIGHT("0" + CSTR(day(MEASURES.currentmemberdate)),2) +  "." + 
    RIGHT("0" + CSTR(month(MEASURES.currentmemberdate)),2) + "." +  
    CSTR(year(MEASURES.currentmemberdate))
    SELECT {MEASURES.currentmemberdate,Measures.RequiredFormat} ON 0
      FROM [Adventure Works]
      where ([Date].[Date].&[20050101])


    Best Regards Sorna

    Tuesday, June 25, 2013 1:01 PM

All replies

  • Hello ,

      Check the below sample from Adventure works

    WITH MEMBER MEASURES.currentmemberdate
    AS
    cdate([Date].[Date].CURRENTMEMBER.MEMBER_CAPTION)
    MEMBER Measures.RequiredFormat
    AS
    RIGHT("0" + CSTR(day(MEASURES.currentmemberdate)),2) +  "." + 
    RIGHT("0" + CSTR(month(MEASURES.currentmemberdate)),2) + "." +  
    CSTR(year(MEASURES.currentmemberdate))
    SELECT {MEASURES.currentmemberdate,Measures.RequiredFormat} ON 0
      FROM [Adventure Works]
      where ([Date].[Date].&[20050101])


    Best Regards Sorna

    Tuesday, June 25, 2013 1:01 PM
  • You don't need a CLR function to do that, that MDX expression should return that string as it is (or is your date in a different format or something?)

    There is a large overhead in calling CLR functions, So in general you should not use them if there is an equivalent way of doing something in MDX.

    There are a large number of sample CLR functions available at http://asstoredprocedures.codeplex.com with the full source code.


    http://darren.gosbell.com - please mark correct answers

    Thursday, June 27, 2013 1:37 PM