I’ve built a BAQ that shows me hours per employee per week. Works fine for starters.
I’m asked to just show the Overtime hours. per week per person.
I can see that the PIVOT Aggregated Formula is where where each sum is calculated.
So, I try to use the condition “case” in the Pivot Aggregated Expression Editor.
But if I put ANYTHING in there that mimics what I’d use in a calculated field the syntax is rejected on the first item.
(case when… will error on ‘(’
case when… will error on ‘case’
What I’m trying to use is:
(case when Sum(LaborHed_PayHours) > 40 then Sum(LaborHed_PayHours) -40 else 0 end)
Can anyone explain what I should be doing in the Expression Editor?
Or maybe I have to go at this with an entirely different approach?
Any help please?
Ben
10.1.500.26
Here is the working query phrase from the first screen shot:
[SubQuery1].[EmpBasic_Name] as [EmpBasic_Name],
[SubQuery1].[1] as [SubQuery1_1],
[SubQuery1].[2] as [SubQuery1_2],
[SubQuery1].[3] as [SubQuery1_3],
[SubQuery1].[4] as [SubQuery1_4],
[SubQuery1].[5] as [SubQuery1_5],
[SubQuery1].[6] as [SubQuery1_6],
[SubQuery1].[7] as [SubQuery1_7],
[SubQuery1].[8] as [SubQuery1_8],
[SubQuery1].[9] as [SubQuery1_9],
[SubQuery1].[10] as [SubQuery1_10],
[SubQuery1].[11] as [SubQuery1_11],
[SubQuery1].[12] as [SubQuery1_12]
from (select
[EmpBasic].[Name] as [EmpBasic_Name],
(DATEPART(WEEK, LaborHed.ClockInDate)) as [Calculated_Week],
[LaborHed].[PayHours] as [LaborHed_PayHours]
from Erp.LaborHed as LaborHed
inner join Erp.EmpBasic as EmpBasic on
LaborHed.Company = EmpBasic.Company
And
LaborHed.EmployeeNum = EmpBasic.EmpID
and ( EmpBasic.OTCalc_c = True )where (LaborHed.ClockInDate > ‘01/01/2018’ and LaborHed.OTEX_c = False and LaborHed.ClockInDate < ‘12/31/2018’)
group by [EmpBasic].[Name],
(DATEPART(WEEK, LaborHed.ClockInDate)),
[LaborHed].[PayHours]) SubQuery1_src
PIVOT
(
Sum(LaborHed_PayHours)
FOR Calculated_Week in ([1],[ 10],[ 11],[ 12],[ 2],[ 3],[ 4],[ 5],[ 6],[ 7],[ 8],[ 9]) )
as SubQuery1