Reputation: 1
I am using Microsoft Query to summarize Excel table like below.
Here Status "W" denotes "Work", "AL" Denotes "Annual Leave" and "CL" Denotes "Casual Leave". Each employee has different status for each day (for 365 days).
| Employee_ID | 1-Jan |2-Jan|3-Jan|4-Jan|......|31-Dec|
| -------- | ----- |-----|-----|-----|......|------|
| John | W |W |W |W |......|CL |
| Paul | W |AL |AL |AL |......|W |
I was trying to aggregate the Status for each month by UNPIVOTING each Day column( i.e 1-Jan, 2-Jan etc..) by using below SQL query
SELECT
Timesheet.Status,
COUNT(Timesheet.Status)
FROM
(
SELECT
`Working$`.Emp_No,
'1-Jan' AS Trn_Date,
`Working$`.`1-Jan` AS Status
FROM
`Working$` `Working$`
UNION ALL
SELECT
`Working$`.Emp_No,
'2-Jan' AS Trn_Date,
`Working$`.`2-Jan` AS Status
FROM
`Working$` `Working$`
)AS Timesheet
WHERE RIGHT(Timesheet.Trn_Date,3) = ?
GROUP BY Timesheet.Status
I have set a parameter to filter the Status Aggregation by month. The above query works fine until 49 "UNION ALL" and then Excel ODBC Driver throws following error "[MICROSOFT][ODBC EXCEL DRIVER]QUERY IS TOO COMPLEX"
Status | EXPR1001 |
---|---|
W | 30 |
CL | 4 |
AL | 7 |
How to overcome this issue. Thanks
Upvotes: 0
Views: 84