SQL Cube-ISO 8601日历插入445个月

时间:2014-04-25 08:22:39

标签: calendar ssas iso iso8601

我对SSAS很新,目前正在构建一个多维数据集。除了我需要使用ISO 8601日历之外,Everthing还可以,但不幸的是,内置功能并不包含月份,只有年,周,日。 我想要实现的目标是添加445个模式的月份,例如报告月份,但使用ISO 8601日历的周,日,年/年开始。

是否可以在不手动编辑日历表的情况下实现此目的?

由于

约翰

2 个答案:

答案 0 :(得分:0)

完全!我终于用这种逻辑做了一些事情:

WHEN [ISO_8601_Week_Of_Year]>=1 AND [ISO_8601_Week_Of_Year]< 5 THEN 'January,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','') 
  WHEN [ISO_8601_Week_Of_Year]>4 AND [ISO_8601_Week_Of_Year]< 9 THEN 'February,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','')
  WHEN [ISO_8601_Week_Of_Year]>8 AND [ISO_8601_Week_Of_Year]< 14 THEN 'March,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','')
  WHEN [ISO_8601_Week_Of_Year]>13 AND [ISO_8601_Week_Of_Year]< 18 THEN 'April,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','')
  WHEN [ISO_8601_Week_Of_Year]>17 AND [ISO_8601_Week_Of_Year]< 22 THEN 'May,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','')
  WHEN [ISO_8601_Week_Of_Year]>21 AND [ISO_8601_Week_Of_Year]< 27 THEN 'June,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','')
  WHEN [ISO_8601_Week_Of_Year]>26 AND [ISO_8601_Week_Of_Year]< 31 THEN 'July,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','')
  WHEN [ISO_8601_Week_Of_Year]>30 AND [ISO_8601_Week_Of_Year]< 35 THEN 'August,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','')
  WHEN [ISO_8601_Week_Of_Year]>34 AND [ISO_8601_Week_Of_Year]< 40 THEN 'September,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','')
  WHEN [ISO_8601_Week_Of_Year]>39 AND [ISO_8601_Week_Of_Year]< 44 THEN 'October,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','')
  WHEN [ISO_8601_Week_Of_Year]>43 AND [ISO_8601_Week_Of_Year]< 48 THEN 'November,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','')
  WHEN [ISO_8601_Week_Of_Year]>47 AND [ISO_8601_Week_Of_Year]<= 52 THEN 'December,'+REPLACE(ISO_8601_Year_Name,'ISO8601 Calendar','')

然后使用另一个这样的查询:

SELECT MIN(ISO_8601_Week) AS 'Month_date',Month_Name
FROM [Reporting].[dbo].[SSAS_Calendar]
GROUP BY Month_Name
ORDER BY Month_date

Month_Name是创建的列,Month_Date返回每个月的开头。

答案 1 :(得分:0)

您可以添加&#34;报告日历&#34;在Visual Studio中。它可以有445模式。但对我而言,它给出了错误的数字,即周数得到周一的年份而不是周四(因为它应该根据ISO)。

选择&#34;新维度......&#34;然后是时间维度选项之一。