Sunday, May 18, 2014

MDX Date Formatting in SSRS

MDX Date Formatting in SSRS:

Suppose there is a Date Dimension in Cube which returns date as below through MDX.


Issues:

  1. Date Format should be "MM/dd/yyyy" like  12/31/2042 in SSRS Reports.
  2. Unknown should appear as Blank.
Condition
          No Admin rights in Cube. We can right expression in SSRS only.

Solution:
         We can use below expression in SSRS report for getting above formatted result:


=IIF(Year( IIF( ISDATE(Fields!Date.Value) = FALSE, "1900-01-01",Fields!Date.Value )  )="1900" , Nothing ,  FORMAT( CDATE( IIF(ISDATE(Fields!Date.Value) = FALSE, "1900-01-01",Fields!Date.Value) )  ,"MM/dd/yyyy"  ) )

After using above expressions, below result will appear on report:

Unknown values are appearing as Blank and other date formatting coming as MDY format.

Thanks.