SSRS - Manager with employees utilized by other managers - reporting-services

I am trying to create an Employee Utilization report in SSRS (Visual Studio 2010, SQL Server 2012)
We have employees who work for multiple program managers. I need a report that shows program managers, the employees who work for them, and the utilization of each employee by each manager they work for. This will allow us to identify which employees do not have their utilization distributed correctly.
The dataset query returns data such as:
EmpID Emp Mgr Util Total Util
1234 Doe, John Lundy, Sal 100 100
2345 Ward, Joe Lundy, Sal 40 110
3456 Kline, Rob Smith, Bob 100 100
4567 Abbott, Fred Smith Bob 100 100
2345 Ward, Joe Smith, Bob 70 110
The results, when grouped by manager, should look like this (with the plus indicating the expand toggle):
Mgr Emp UtilMgr Util Total Util
Lundy, Sal
+Doe, John 100
+Ward, Joe 110
Smith, Bob
+Kline, Rob 100
+Abbott, Fred 100
+Ward, Joe 110
When an employee is expanded, the detail will show the employee utilization broken down by the different program managers they do work for:
Mgr Emp UtilMgr Util Total Util
Lundy, Sal
-Doe, John 100
Lundy, Sal 100
-Ward, Joe 110
Lundy, Sal 40
Smith, Bob 70
Smith, Bob
+Kline, Rob 100
+Abbott, Fred 100
+Ward, Joe 110
I have tried all kinds of grouping and property combinations (parents, children, display detail) in the report, but cannot get the results to be grouped the way I want it. I tried adding another manager field (aliased as UtilMgr) to the query, but still couldn't get the report correct.
I'm looking for the best way to handle this. It seems like the solution is to have the Program Manager as a parent to the Employee, and then have a second group where the Employee is a parent to the Manager, but I'm not sure how to implement that.
Do I need to do something different with the query? Do I need to use a subreport or a second matrix, nested in the first? Is there some way to create overlapping parent/child groups?
I have only been working with SSRS for about 2 weeks, so I hope all the terminology I've used is clear and correct. Thanks in advance for any help!

Can you change your query?
In order to do what you want, your dataset needs to look like this:
EmpID Emp Mgr UtilMgr Util Total Util
1234 Doe, John Lundy, Sal Lundy, Sal 100 100
2345 Ward, Joe Lundy, Sal Lundy, Sal 40 110
2345 Ward, Joe Lundy, Sal Smith, Bob 70 110
3456 Kline, Rob Smith, Bob Smith, Bob 100 100
4567 Abbott, Fred Smith, Bob Smith, Bob 100 100
2345 Ward, Joe Smith, Bob Smith, Bob 70 110
2345 Ward, Joe Smith, Bob Lundy, Sal 40 110

Related

How to identify which new rows were added in SQL Server 2014

Suppose I have a table like this:
name position zipcode
-------------------------
Gary Gm 12345
Rob VP 54321
John Manager 1234
After 20 minutes some rows were added in the source and now the table looks like
name position zipcode
------------------------
Gary Gm 12345
Rob VP 54321
John Manager 1234
Chris Director 5478
Kane VP 9999
So Kane and Chris were added after 20 minutes in the source, and there is no date time field to identify on which day the rows were added, I just wanted to know if there are any functions to identify the newly added rows in the table in SQL Server 2014?

prediction on rowwise data or progressive data

I am working on employee attrition analysis with a table having rowwise data for a (employee like Id, name, Date_Join Date_Relieving Dept Role etc)
eID eName Joining Releiving Dept Married Experience
123 John Doe 10Oct15 12Oct16 HR No 12
234 Jen Doee 01jan16 -NA- HR No 11 (ie she is available)
I can run regression on this data to find the beta coefficient
eID eName Joining Releiving Dept Married Experience
123 John Doe 10Oct15 12Oct16 HR No 12
234 Jen Doee 01jan16 -NA- HR No 11
But I've seen other approach too.. where employee have multiple entries depending on their difference between joining date and current month or relieving month(say Employee A joined in Jan and Left in Dec so he'll have 12 entries updating corresponding columns like experience and marriage etc)
eID eName Dept Married Experience
123 John Doe HR No 0
123 John Doe HR No 1
123 John Doe HR Yes 2
123 John Doe HR Yes 3
can someone tell what differentiate two approaches.. and what is the outcome of this second approach.

how we can give value using keyboard in mysql

In Oracle you can SELECT data from a table and request interactive user input to be used in the WHERE condition. This is done by specifying &column in the WHERE statement and user input will be prompted and used in its place. For example:
SELECT Ename, Deptno, Job, Sal FROM Emp
WHERE Sal &GiveNegationState BETWEEN 1100 AND 2850
SQL> /
Enter value for givenegationstate: NOT
ENAME DEPTNO JOB SAL
---------- ---------- --------- ----------
KING 10 PRESIDENT 5000
JONES 20 MANAGER 2975
JAMES 30 CLERK 950
FORD 20 ANALYST 3000
SMITH 20 CLERK 800
SCOTT 20 ANALYST 3000
Can this be done in MySQL?

Mysql Query Studied Days

I have Emp table with following values
Emp_Id Emp_Name Subject Dates
001 Smith Java 07-02-2012
001 Smith oracle 08-02-2012
001 smith C++ 10-02-2012
002 john java 01-01-2012
002 john SE 10-01-2012
002 john c 10-01-2012
001 smith physics 04-01-2012
001 smith c# 07-02-2012
001 smith javascript 07-02-2012
Now as we can see here smith studied only 3 days for month February and 1 for month Jan
while john studied only 2 days for month January.
How can we calculate this count for any employee?
As a e.g:Output should be in following way.
Emp_Id Emp_Name Month_Year No_Of_Days_Studied_In_Month
001 smith Feb12 3
001 smith Jan12 1
002 john Jan12 2
You can GROUP BY YEAR(Dates), MONTH(Dates) and do a COUNT.
TRY:
SELECT emp_id,
emp_name,
Date_format(DATE, '%b%y') AS dates,
COUNT(*) AS No_Of_Days_Studied_In_Month
FROM emp
GROUP BY Date_format(DATE, '%b%y'), emp_name
ORDER BY emp.emp_id

10 period moving average in MySql without using date

I have a table of goalie data, snipet below
year gameid player sv% gamenum
2009 200165 John Smith 0.923 0165
2009 209754 John Smith 1.000 9754
2009 206938 John Smith 1.000 6938
2009 206155 John Smith 0.833 6155
2009 203021 John Smith 0.667 3021
2009 206472 John Smith 0.909 6472
2009 209524 John Smith 0.833 9524
2009 209351 John Smith 0.800 9351
2009 203056 John Smith 1.000 3056
2009 206761 John Smith 0.935 6761
2009 200466 John Smith 0.954 0466
2009 204171 John Smith 0.932 4171
2009 207876 John Smith 0.958 7876
2009 201581 John Smith 0.941 1581
2009 205286 John Smith 0.930 5286
2009 208991 John Smith 0.961 8991
2009 202696 John Smith 0.916 2696
2009 206401 John Smith 0.935 6401
2009 200106 John Smith 0.921 0106
2009 201381 John Smith 0.918 1381
I want to get the 10 game moving averages for each goalie, but I don't have dates or game numbers such as his first, second, third game, etc. The game ids are also assigned in the order they are played at the league level, so game 200106 could be his first game of season, and 200165 could be his 2nd, and so on.
My question is: How can I get the max(10 game moving average) and min(10 game moving average) grouped by each goalie for each year?
Also, is there a way to rank the game ids by goalie, year using MySql?
A 10 game moving average means that if you had less than 10 games, there is no meaningful average (not enough games). If you had 12 games, the average is taken between
1-10 (avg)
2-11 (avg)
3-12 (avg)
max / min across the 3 averages
The most efficient way to do this in MySQL would be to
select .. (involving 13 #variables to rownumber and rotate the last
10 values into the variables, keeping track of
#player, #year, #rownumber)
order by player, year, gameid
This will pass through the data only once, building the averages. An outer query will simply take min/max from this derived table. I'm not up for fleshing this out at the moment though.
This is one idea (fair warning:not tested)
SELECT max(mavg) FROM
(SELECT (SELECT avg(avgfield),min(gamenum) as gn FROM YourTable g WHERE g.gamenum>t.gamenum LIMIT 10),t.gamenum
FROM
YourTable t
) d
or
SELECT max(mavg) FROM
(SELECT t.gamenum FROM
YourTable t INNER JOIN
(SELECT avg(avgfield),min(gamenum) as gn FROM YourTable g WHERE g.gamenum>t.gamenum LIMIT 10) q ON q.gn = t.gamenum
) d