Wednesday, March 7, 2012

DateTime and Date problem

I have created a cube with two dimensions in as2005. A time dimension and a "data" dimension. The "data" dimension is a table from a db that has a field called "ItemDate" that is of type DateTime. In the Dimension usage panel of the cube designer I create a reference in the time row to the "ItemDate" in the data dimension. The problem arises when I want to count how many "data" rows have a date of "March 27 2002". It will only count the rows with a datetime that is "3/27/2002 12:00:00 AM". All the rows that are "3/27/2002 1:45:01 PM" or anything else get ignored. Is there a way to solve this problem in analysis server 2005. Can I convert the datetime to a date or change the reference in some way.
note: I have simplified the problem and striped away names and dimensions to make it less confusing.

Assuming that the "data" dimension source is SQL Server, you can add a Named Calculation to the Data Source View, like "ItemDateOnly", defined as:

convert(datetime, convert(varchar, ItemDate, 101))

This new column could be used to join to a normal date dimension.|||Thanks, I was trying to create a calculated field in the cube with MDX. The calculated field in the data source view opens up many solutions.

No comments:

Post a Comment