0
votes

I have this MDX that shows the measures for specific Ad Name in the last 4 months:

WITH 
  SET [Selected Measures] AS 
    {
      [Measures].[Cost]
     ,[Measures].[Clicks]
    } 
SELECT 
  [Selected Measures] ON COLUMNS
 ,NonEmpty
  (
    (
      [Ad Name Dim].[Ad Name].[Name].ALLMEMBERS
     ,
        ClosingPeriod
        (
          [Time Dim].[Time Dim].[Month]
         ,[Time Dim].[Time Dim].[All Time]
        ).Lag(3)
      : 
        ClosingPeriod
        (
          [Time Dim].[Time Dim].[Month]
         ,[Time Dim].[Time Dim].[All Time]
        )
    )
  ) ON ROWS
FROM [CubeName];

And I would like to add another field that would be available to me in SSRS report, that will show the first date that the specific ad had data on

Something like Min([Time Dim].[Time Dim].[Day]).

2

2 Answers

0
votes

Not tested - if you can translate to a script against the AdvWorks cube then it's easier for contributors:

WITH 
  SET [Selected Measures] AS 
    {
      [Measures].[Cost]
     ,[Measures].[Clicks]
    } 
  MEMBER [Measures].[MinDate] AS 
    Head
    (
      NonEmpty
      (
        [Time Dim].[Time Dim].[Month] //<<to return minimum month but could be changed to a different level
       ,(
          [Selected Measures]
         ,[Ad Name Dim].[Ad Name].CurrentMember
        )
      )
     ,1
    ).Item(0).Item(0).Member_Caption 
SELECT 
  {
    [Selected Measures]
   ,[Measures].[MinDate]
  } ON COLUMNS
 ,NonEmpty
  (
    (
      [Ad Name Dim].[Ad Name].[Name].ALLMEMBERS
     ,
        ClosingPeriod
        (
          [Time Dim].[Time Dim].[Month]
         ,[Time Dim].[Time Dim].[All Time]
        ).Lag(3)
      : 
        ClosingPeriod
        (
          [Time Dim].[Time Dim].[Month]
         ,[Time Dim].[Time Dim].[All Time]
        )
    )
  ) ON ROWS
FROM [CubeName];
0
votes

How about this(NOT TESTED):

With SET [Selected Measures] AS { [Measures].[Cost]
                            ,[Measures].[Clicks]  } 

SET SetOfMonths as ClosingPeriod([Time Dim].[Time Dim].[Month], 
[Time Dim].[Time Dim].[All Time]).Lag(3):ClosingPeriod([Time Dim].[Time Dim].[Month])

SET FirstDay as
HEAD([Time Dim].[Time Dim].[Day], 1)

SELECT  [Selected Measures]  ON COLUMNS,
nonempty(([Ad Name Dim].[Ad Name].[Name].allmembers,
SetOfMonths, FirstDay,     
[Time Dim].[Time Dim].[All Time])) ON ROWS
FROM [CubeName]