Daily reads for the last 3 months

My date dimension is Year-Month-Day.

I can use the LastPeriods function to retrieve the last X days of readings:

LastPeriods(7, 
StrToMember
(
"[Date].[Year Week Day].[Date].&[" + FORMAT(Now(),"yyyy-MM-ddT00:00:00") +"]"
)   
)

I now need to retrieve daily readings for the current quarter. I think I need to use the current date and quarter and calculate the range from the start of the quarter to the current date as my LastPeriods value. This will give me number of days from the start of the current quarter to current day.

I also need to return the last 3 months from the current day. So should I just roll back 12 weeks from today, i.e. 12*7 = 84 days = LastPeriods(84.... 

August 17th, 2015 10:00am

Hi D,

For all days in the current quarter, you could navigate to the first day of the quarter using .parent and .firstchild. For example, if your hierarchy was Year, Quarter, Month, Day, instead of LastPeriods, you could use

StrToMember
(
"[Date].[Year Week Day].[Date].&[" + FORMAT(Now(),"yyyy-MM-ddT00:00:00")
+"]"
).parent.parent.firstchild.firstchild

:StrToMember
(
"[Date].[Year Week Day].[Date].&[" + FORMAT(Now(),"yyyy-MM-ddT00:00:00")
+"]"

Hope that helps,


Free Windows Admin Tool Kit Click here and download it now
August 18th, 2015 12:05am

Hi DarrenOD,

According to your description, you want to get set of members in last 3 months. Right?

In this scenario, since each month has different days, it's not accurate to use previous 84 days in LastPeriods() function. For your requirement, we can use ParallelPeriod() function and specify the level expression we need. So your expression can be like:

ParallelPeriod(
[Date].[Year Week Day].[Month],3,
StrToMember
(
"[Date].[Year Week Day].[Date].&[" + FORMAT(Now(),"yyyy-MM-ddT00:00:00")
+"]"
)
)
:
StrToMember
(
"[Date].[Year Week Day].[Date].&[" + FORMAT(Now(),"yyyy-MM-ddT00:00:00")
+"]"
)
 

Reference:
ParallelPeriod (MDX)

Regards,

August 18th, 2015 3:29am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics