Named Set for Time Dimension

Can anyone suggest how I can create a named set for my time dimension (days) that automatically includes aa rolling 30 day period (i.e. today plus 30 days previous)?

Hello, Alan, i’m not sure if you know how MDX works for namedsets, but with your explanation i got this, what it does is taking today plus 30 days before:

Filter(
Descendants([Time].[Default].[ALL], , Leaves),
MID([Time].Default.currentmember.properties(“key”), 1, 4) = CStr(Year(now())) and
[Time].Default.currentmember.properties(“key”) >=
CStr(Year(DateAdd(“d”, -30, Now()))) + “D” + Right(“000” + CStr(DatePart(“y”, DateAdd(“d”, -30, Now()))), 3) and
[Time].Default.currentmember.properties(“key”) <=
CStr(Year(Now())) + “D” + Right(“000” + CStr(DatePart(“y”, Now())), 3)
)
image

Remember to change the [Time] to your Time name dimension.
Let me know if it works

2 Likes

Have you tried using Parallel_Period()?

1 Like

Hi Ali. Thank you for replying, but I don’t know what that means.

Hi Matheus. Thank you for your reply. When I enter that MDX into the expression editor, it fails (red box - can’t save). I’ve replaced [Time] with [Flash Time] which is my time dimension name. I did think it might be missing a closing parenthesis but that didn’t help.

Hello, Alan, it looks like the forums was changing the quotation marks, try this now, just change the [tempo] to your time dimension name.

Filter(
Descendants([tempo].[Default].[ALL], , Leaves),
MID([tempo].Default.currentmember.properties("key"), 1, 4) = CStr(Year(now())) and
[tempo].Default.currentmember.properties("key") >=
CStr(Year(DateAdd("d", -30, Now()))) + "D" + Right("000" + CStr(DatePart("y", DateAdd("d", -30, Now()))), 3) and
[tempo].Default.currentmember.properties("key") <=
CStr(Year(Now())) + "D" + Right("000" + CStr(DatePart("y", Now())), 3)
)

Hi Matheus. Perfect! Thank you :slight_smile:

1 Like