Forum Discussion
Direct query _Mid suffix results in count
Hi Davem
Not quite understand your logic, please refer to https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490 for how to get your question answered quickly.
Hi thanks for the reply, I am just trying to total hours and activity counts based on tasks completed in our facility. If I use the SQL below to pull in sums from SQL Server 2017, MoveOrder_AM, MoveOrder_PM & MoveOrder_WKD all correctly load into Power BI as summed values but the MID reference causes that field to count for some reason. If I change the SQL AS reference for that field to be anything other than MID ie MoveOrder_MD, it works correctly. I just thought it was odd that the MID reference would cause this behaviour?
SELECT TD.Ddate
, SUM(CASE WHEN TD.[taskid] = 2 AND TD.[ShiftID] = 1 THEN TD.[linestickets] ELSE 0 END) AS MoveOrder_AM
, SUM(CASE WHEN TD.[taskid] = 2 AND TD.[ShiftID] = 2 THEN TD.[linestickets] ELSE 0 END) AS MoveOrder_PM
, SUM(CASE WHEN TD.[taskid] = 2 AND TD.[ShiftID] = 3 THEN TD.[linestickets] ELSE 0 END) AS MoveOrder_MID
, SUM(CASE WHEN TD.[taskid] = 2 AND TD.[ShiftID] = 4 THEN TD.[linestickets] ELSE 0 END) AS MoveOrder_WKD
FROM tblTaskDetail TD
GROUP BY TD.Ddate;