Answered by:
SSAS Named Set Using [Dim Date].[START OF WEEK STARTING SUN DATE]

Question
-
I'm trying to create a named set in my cube. In my date dimension I've got the both [Date] and [Start of week starting sun date]. What I want to do is create a named set using [Start of week starting sun date] and have it give me the most recent 4 weeks. So to recap, the data looks like this:
DATE START OF WEEK STARTING SUN DATE 7/1/2016 6/26/2016 7/2/2016 6/26/2016 7/3/2016 3/3/2016 7/4/2016 3/3/2016 7/5/2016 3/3/2016 7/6/2016 3/3/2016 7/7/2016 3/3/2016 What I've tried to implement for the named set is as follows:
{ strtomember("[Dim Date].[START OF WEEK STARTING SUN DATE].&[" + cstr(year(now())) + "-" + Right('0'+ cstr(Month(dateadd('m',-1,now()))),2) + "-" + Right('0'+ cstr(Day(now())),2)+ "T00:00:00]") : strtomember("[Dim Date].[START OF WEEK STARTING SUN DATE].&[" + cstr(year(now())) + "-" + Right('0'+ cstr(Month(now())),2) + "-" + Right('0'+ cstr(Day(now())),2)+ "T00:00:00]")}
This approach works when I use just [Dim Date].[Date] however when I substitute that with [Dim Date].[START OF WEEK STARTING SUN DATE] I start running into problems due to the fact that not every date exists in [Dim Date].[START OF WEEK STARTING SUN DATE]. My question is, how could I implement something like this?
- Moved by Just Karl Wednesday, August 3, 2016 1:31 PM Looking for the correct forum.
Tuesday, August 2, 2016 1:27 PM
Answers
-
Hello,
The SQL Server forums are over here:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/home
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
My Blog: Unlock PowerShell
My Book: Windows PowerShell 2.0 Bible
My E-mail: -join('6D73646E5F6B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})- Proposed as answer by Dave PatrickMVP Wednesday, August 3, 2016 1:42 PM
- Marked as answer by rockit Wednesday, August 3, 2016 1:44 PM
Wednesday, August 3, 2016 1:31 PM
All replies
-
Hello,
The 'Academic Initiatives - Technical Queries' forum is for posts Related to technical / coding / programming related issues as related to Microsoft's Academic Initiatives.
As it's off-topic here, I am moving the question to the Where is the forum for... forum.
Karl
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
My Blog: Unlock PowerShell
My Book: Windows PowerShell 2.0 Bible
My E-mail: -join('6D73646E5F6B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})Wednesday, August 3, 2016 1:30 PM -
Hello,
The SQL Server forums are over here:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/home
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
My Blog: Unlock PowerShell
My Book: Windows PowerShell 2.0 Bible
My E-mail: -join('6D73646E5F6B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})- Proposed as answer by Dave PatrickMVP Wednesday, August 3, 2016 1:42 PM
- Marked as answer by rockit Wednesday, August 3, 2016 1:44 PM
Wednesday, August 3, 2016 1:31 PM