简体   繁体   中英

MDX Date hierarchy to date format in Excel

I'm using a Excel pivot table to analyze a SSAS multidimensional cube. I have a date hierarchy with

year --> month --> date

that looks like that:

在此输入图像描述

In order to use the excel time slicer, the column has to be in a date format. Does anyone have an idea how to change the date column to a date format within Excel?

I have the feeling it has to be within Excel.

This old white paper documents how to properly mark a Date dimension so that Excel treats it as such. You will need to make a few small changes to your cube and redeploy it. See Figure 29-31 which show how to mark Type=Time on the dimension and set the ValueColumn on the key of the dimension.

To designate a time dimension, set the Type property of the dimension to Time, as illustrated in Figure 29.
在此输入图像描述

Figure 29. Setting the dimension Type property to Time

Exposing Date-Specific Filtering Options If a dimension, in addition to having the Type property set to Time, also has a date property, Office Excel 2007 PivotTables expose date-specific filtering options for this dimension's hierarchies instead of label filtering options. In Analysis Services, you do this by having a date data type column in the data source view tables for the time dimension and then setting the ValueColumn property to point to that column, as illustrated in Figure 30. To enable date filtering in the PivotTable, first set the Type of the dimension to Time.
在此输入图像描述

Figure 30. Setting the dimension type to Time to expose date filtering options

Next, set the ValueColumn property of the key attribute hierarchy in the time dimension to point to a date data type column in the source database. The DataType property should be set to Date, as illustrated in Figure 31.
在此输入图像描述

Figure 31. Setting the ValueColumn of the key attribute hierarchy to a date type column

You could run TextToColumn while specifying a DMY format a achieve true dates then set the desired date format. This should be performed on the pre-pivot data.

Sub numberformats()
    With ActiveSheet
        With .Range("Z:Z")
            .TextToColumns Destination:=.Cells(1), DataType:=xlFixedWidth, _
                           FieldInfo:=Array(0, xlYDMFormat), TrailingMinusNumbers:=True
            .NumberFormat = "yyyymmdd"
        End With
    End With
End Sub

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