Quantcast
Channel: SQL Server Analysis Services Forum
Viewing all articles
Browse latest Browse all 2472

Adding Another Parameter to MDX Query

$
0
0

I have the following MDX query which I inherited:

WITH 

MEMBER [Time].[Year - Month].[YTD] AS AGGREGATE(YTD(StrToMember(@SelectedMonth, CONSTRAINED)))

--< We need to OT over the individual months in YTD >--
MEMBER [Measures].[Overtime Hours] AS 
  IIF([Time].[Year - Month].CurrentMember = StrToMember(@SelectedMonth, CONSTRAINED), 
    [Measures].[Employee Overtime Hours], 
    SUM(YTD(StrToMember(@SelectedMonth, CONSTRAINED)), [Measures].[CALCED OT]))

MEMBER [Measures].[Overtime Hours %] AS '[Measures].[Overtime Hours] / [Measures].[Available Hours minus PTO]'
	
SELECT 
  {
    [Measures].[Employee Hours],
    [Measures].[Employee Hours %],
    [Measures].[Overtime Hours],
    [Measures].[Overtime Hours %],
    [MEasures].[Available Hours]
  } ON COLUMNS,
  NON EMPTY CROSSJOIN(
    FILTER(
IIF(@SelectedDiscipline = @SelectedDepartment,
      DESCENDANTS(StrToMember(@SelectedDiscipline, CONSTRAINED), [Employee].[DISC - DEPT - EMP].[Department], AFTER),
      DESCENDANTS(StrToMember(@SelectedDepartment, CONSTRAINED), [Employee].[DISC - DEPT - EMP].[Department], AFTER)
), 
      NOT INSTR([Employee].[Department].CurrentMember.MEMBER_NAME, "Freelance")),
    [Employee].[Employee Bill Rate].[Employee Bill Rate].ALLMEMBERS,
    [Employee].[Employee Level].[Employee Level].ALLMEMBERS,
    {
                	-- PTO Utilization Category excluded
		-- PRODUCTION Utiltization Category included with detail
		CROSSJOIN(
			{[Employee Hours Time Category].[Utilization Category].[Utilization Category].&[PRODUCTION]},
			[Employee Hours Time Category].[Time Category].[Time Category].ALLMEMBERS),
		-- ADMIN Utiltization Category rolled-up witout detail
		CROSSJOIN(
			{[Employee Hours Time Category].[Utilization Category].[Utilization Category].&[ADMIN]},
			{[Employee Hours Time Category].[Time Category].[Admin]})
                   },
                   {StrToMember(@SelectedMonth, CONSTRAINED), [Time].[Year - Month].[YTD]}
          ) DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM [OLSON BI] 
CELL PROPERTIES 
  VALUE
,BACK_COLOR
,FORE_COLOR
,FORMATTED_VALUE
,FORMAT_STRING
,FONT_NAME
,FONT_SIZE
,FONT_FLAGS;

The query takes two parameters - Discipline and Department. The available values for Department depend on the value of the Discipline chosen. This is handled by an MDX shared dataset. What I need to do is add another parameter. This parameter is @Employee - and can have multiple values. These values will depend on the value that is chosen for the Department. The hierarchy is DISCIPLINE - DEPARTMENT - EMPLOYEE. So the member would look like [Employee].[DISC-DEPT-EMP].[Employee Full Name].

I'm guessing it would need to be added after the IIF statement where [Employee Level] and [Employee Bill Rate] are selected, just not sure how to modify the query.

This is how the MDX query looks that populates the available values for Employee Full Name:

WITH 

MEMBER [Measures].[ParameterCaption] AS [Employee].[DISC - DEPT - EMP].CURRENTMEMBER.MEMBER_CAPTION 
MEMBER [Measures].[ParameterValue] AS [Employee].[DISC - DEPT - EMP].CURRENTMEMBER.UNIQUENAME 
MEMBER [Measures].[ParameterLevel] AS [Employee].[DISC - DEPT - EMP].CURRENTMEMBER.LEVEL.ORDINAL 

SELECT 
  {
    [Measures].[ParameterCaption]
   ,[Measures].[ParameterValue]
   ,[Measures].[ParameterLevel]
  } ON COLUMNS
 ,[Employee].[DISC - DEPT - EMP].[Employee Full Name].ALLMEMBERS ON ROWS
FROM 
(
  SELECT 
    StrToSet
    (@Department
     ,CONSTRAINED
    ) ON COLUMNS
  FROM 
  (
    SELECT 
      StrToSet
      (@Discipline
       ,CONSTRAINED
      ) ON COLUMNS
    FROM [OLSON BI]
  )
);

Any input would be greatly appreciated!!

Thanks!


A. M. Robinson


Viewing all articles
Browse latest Browse all 2472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>