问题描述
我需要将成员值从这种格式dd.MM.yyyy
转换为CDate.
这是我的审判:
I need to convert a member value from this format dd.MM.yyyy
into a CDate.
This was my trial:
cdate(format([Date].[Date].CURRENTMEMBER.MEMBER_VALUE, "dd.MM.yyyy"))
来源: http://www.datazen.com /blogs/post/working-with-dates-in-datazen-3-0
cdate(format([Date].[Date].CURRENTMEMBER.MEMBER_VALUE, "dd.MM.yyyy"))
Source: http://www.datazen.com/blogs/post/working-with-dates-in-datazen-3-0
但是,我收到类型不匹配错误,因为格式功能ist无法正常工作.
我正在使用Microsoft Analysis Server.
However, I get a type mismatch error, because the format function ist not working properly.
I'm using a Microsoft Analysis Server.
有人知道该问题的解决方案吗?
Do someone know a solution for this issue?
推荐答案
您需要创建何时提取日期的度量.
You need to create a measure when to extract the date.
这是一条可能的路线:
MEMBER [Measures].[Date as int] as
[Date].[Date].CURRENTMEMBER.Properties('Key0', Typed)
MEMBER [Measures].[Date Year] as
Fix([Measures].[Date as int] / 10000)
MEMBER [Measures].[Date Month] as
Fix(([Measures].[Date as int] - [Measures].[Date Year] * 10000) / 100)
MEMBER [Measures].[Date Day] as
[Measures].[Date as int] - [Measures].[Date Year] * 10000 - [Measures].[Date Month] * 100
MEMBER [Measures].[DateValue_attempt1] as
// convert it to Date data type and use a format string on that:
DateSerial([Measures].[Date Year], [Measures].[Date Month], [Measures].[Date Day]),
format_string = 'dd.MM.yyyy'
MEMBER [Measures].[DateValue_attempt2] as
//if above fails maybe just convert it to string & do further conversion in client
[Measures].[Date Day] + "." +
[Measures].[Date Month] + "." +
[Measures].[Date Year]
这篇关于MDX-将会员价值转换为CDate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!