Below query compute the percent of work employee wise. i.e. employee on rows and percent of work on columns
With Member [Measures].[EmployeeWisePercent] AS
[Measures].[Hours] / ([Employee].[Employee].[All], [Measures].[Hours]) * 100
Member [Measures].[TotalHours] AS
([Employee].[Employee].[All], [Measures].[Hours])
SELECT NON EMPTY
{ [Measures].[Hours], [Measures].[EmployeeWisePercent], [Measures].[TotalHours] } ON COLUMNS,
NON EMPTY
{ ([Employee].[Employee].[Employee].ALLMEMBERS ) }
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM
( SELECT ( STRTOSET("[Date].[Calendar].[All]", CONSTRAINED) ) ON COLUMNS FROM
( SELECT ( STRTOSET("[Project].[Project Name].&[Self Study]", CONSTRAINED) ) ON COLUMNS FROM
[TimeSheetHours Cube]))
WHERE ( IIF( STRTOSET("[Project].[Project Name].&[Self Study]", CONSTRAINED).Count = 1,
STRTOSET("[Project].[Project Name].&[Self Study]", CONSTRAINED),
[Project].[Project Name].currentmember ),
IIF( STRTOSET("[Date].[Calendar].[All]", CONSTRAINED).Count = 1,
STRTOSET("[Date].[Calendar].[All]", CONSTRAINED), [Date].[Calendar].currentmember ) )
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
Output is something like following
Employee Name | Hours | Percent | Total Hours
Employee1 | 975.86 | 1.32 | 73421.22
Employee2 | (null) | (null) | 73421.22
Employee3 | (null) | (null) | 73421.22
Employee4 | (null) | (null) | 73421.22
Employee5 | (null) | (null) | 73421.22
Employee6 | (null) | (null) | 73421.22
...
...
...
I need to update above query to get the employee count and group it like (0-20%, 20-40%, ... etc.) on rows and count of employee that falls in that range on columns. Something like below:
Employee Name | EmployeeCount
0-20% | 5
20-40% | 8
40-60% | 88
60-80% | 2
80-100% | 1
Is there any way we can group percent count on the range specified above? Please help me to prepare mdx query to get desired output.
Note: I don't need employee name on rows as it appears as of now.
Your requirement as I understand is to basically create two calculated measure(Count of Employees and percentage Bracket) and display the aggregated results of one measure against the other. This basically translates to something like(pseudo code below) -
While this is possible in a bit complicated SQL, it is not possible in MDX. The main reasons is that what you want here is a two-step calculation. The first step would calculate the bracket in which employee would fall and in the next step, use this result to get the counts per bracket. It might seem that this can be achieved using calculated members, but you have to keep in mind that measure values are not persistent. In absence of a scope, a measure is aggregated over the entire hierarchy. There is no way to deduce the unique values a measure can contain unless the MDX is run.
In SQL, this can be achieved using
subquery
orjoin
because joins could be made at the aggregated values(and they are treated persistent), but that feature does not exist in MDX.What IS possible is to have 5 separate calculated members which would hold counts per bracket. As this would be a one step calculation, it would be within the powers of MDX.
It would be something one the lines of below -