This is a proof of what is happening:
WITH
MEMBER measures.NumberOfSameWeekDays AS
Count([Date].[Day of Week].CurrentMember)
MEMBER measures.WeekDayCurrentMem AS
[Date].[Day of Week].CurrentMember.Member_Caption
SELECT
{
measures.NumberOfSameWeekDays
,measures.WeekDayCurrentMem
} ON COLUMNS
,[Date].[Day of Week].[Day of Week] ON ROWS
FROM [Adventure Works]
WHERE
[Date].[Calendar].[Date].&[20050101]
:
[Date].[Calendar].[Date].&[20050116];
Here is the result of the above:
Here is a solution to the above behaviour:
WITH
MEMBER measures.NumberOfSameWeekDays AS
Count
(
(EXISTING
[Date].[Day of Week].CurrentMember * [Date].[Calendar].[Date])
)
SELECT
{
measures.NumberOfSameWeekDays
} ON COLUMNS
,[Date].[Day of Week].[Day of Week] ON ROWS
FROM [Adventure Works]
WHERE
[Date].[Calendar].[Date].&[20050101]
:
[Date].[Calendar].[Date].&[20050131];
This returns the following:
A simplified version of Sourav's answer - although still rather complex - and potentially slow as it uses Generate which is iterative:
WITH
MEMBER Measures.CountOfDays AS
Generate
(
(EXISTING
[Date].[Date].[Date].MEMBERS)
,[Date].[Day of Week]
,ALL
).Count
SELECT
Measures.CountOfDays ON 0
,[Date].[Day of Week].[Day of Week].MEMBERS ON 1
FROM [Adventure Works]
WHERE
[Date].[Calendar].&[2005] : [Date].[Calendar].&[2006];
Count( <some hierarchy used on rows>.currentmember)
...because 1 member is currently in the context of the resultset. – whytheq.CurrentMember
is a function that returns the member on the row - if a row has one member on it, then it returns 1. No example required. In your script for the row that says Tuesday the.Currentmember
function is counting how many times it has Tuesday on the Tuesday row .... 1. – whytheq