Showing posts with label quarter. Show all posts
Showing posts with label quarter. Show all posts

Thursday, March 22, 2012

calculated DistinctCount over two levels of "incomplete" weeks

Hello all,
I have a cube on as2005 where my Time dimension has 5 levels(year, month, quarter, week, day) and a measure that is a distinct count of customers (I also have a customer dimension, with 1 level: customer)

In my time dim, I have "incomplete" weeks, for example the week 32 exist on both august and september months, 5 days of the week in august and 2 days in september.
So at week level I get the distinct customers for that week, for example:
month | week | # distinct customers
AUG | 32 | 15
SEPT | 32 | 20

but, since the week is the same, i want to get the distinct customers for the whole week, and put it on the last month where that week appears, in the example let's say that for week 32 there are 18 different customers, I want a 18 on SEPT.

month | week | # distinct customers
AUG | 32 | NULL
SEPT | 32 | 18

Someone know how can I achieve this?
Thanks!I've found the way to do this, I hope this helps the community!

Aggregate
(
UNION([DM Time].[Hierarchy].CurrentMember.PrevMember.Children,[DM Time].[Hierarchy].CurrentMember.Children)
,[Measures].[# Customers]
)

only for the scope of the week.

Tuesday, March 20, 2012

Calculate Quarter

Hi,

I need to retrieve both Mont and Quarter from an MS SQL server field containing a date as ''01/01/2007 12:10:00'.

Retrieving the Month is working properly, but getting some sql error with the Quarter function.

I will appreciate if someone can indicate me how should I do in order to retrieve the Quarter from a date.

To retrieve the month, I am using:

& "MONTH(STOCK.VALUEDATE) AS 'Month'"

To retrieve the Quarter, I am trying (but getting error):

& "QUARTER(STOCK.VALUEDATE) AS Quarter"
Thanks,

Aldo.

I already got the answer...

& "STOCK.VALUEDATE AS 'Original Date', " _
& "DATEPART(month, STOCK.VALUEDATE) AS 'Month', " _
& "DATEPART(quarter, STOCK.VALUEDATE) AS 'Quarter', " _
& "DATEPART(year, STOCK.VALUEDATE) AS 'Year', " _
Thanks anyway,

Aldo.

|||Aldo,
Please use the Transact-SQL forum for these kinds of questions. This has nothing to do with SSIS.

Thanks,
Phil