Hi,
I'm currently writing a report that looks at staff sales but have a problem where all sales that are finalised on days that they're not due to work are getting omitted. Due to the way that I have to do other things, I need to group working time records by day & then add sales on in a later query. Clearly if there was a record for each staff member for every day whetehr they work or not, all sales would be correctly attributed but I'd like to avoid having to create a table full of zero values for 3000 staff if I can. I have created a 'calendar' table with all dates in but that still doesn't seem to work. The SQL I'm using is as follows -
PARAMETERS [Forms]![Productivity_Dates]![DateFrom] DateTime, [Forms]![Productivity_Dates]![DateTo] DateTime;
TRANSFORM IIf(Sum([Tbl_TCS (Total)]![Minutes]) Is Null,0,Sum([Tbl_TCS (Total)]![Minutes])) AS Minutes
SELECT [Tbl_TCS (Total)].[Staff ID], [Tbl_TCS (Total)].[Data Date]
FROM Tbl_Calendar LEFT JOIN [Tbl_TCS (Total)] ON Tbl_Calendar.Date = [Tbl_TCS (Total)].[Data Date]
WHERE ((([Tbl_TCS (Total)].[Data Date]) Between [Forms]![Productivity_Dates]![DateFrom] And [Forms]![Productivity_Dates]![DateTo]))
GROUP BY [Tbl_TCS (Total)].[Staff ID], [Tbl_TCS (Total)].[Data Date]
PIVOT [Tbl_TCS (Total)].[Work Code];
Anyone give me a pointer (as you'll have guessed I'm a bit of a newbie at this) as to how I can get my crosstab to enter a date then zero values for each day in the range for each member of staff ?
[Tbl_TCS (Total)] is where all of the working time data is held with [Staff ID] being the person [Work Code] being what they're actually doing (several different types of work) & [Minutes] for how long on each day ([Data Date])
Thanks
Steve
I'm currently writing a report that looks at staff sales but have a problem where all sales that are finalised on days that they're not due to work are getting omitted. Due to the way that I have to do other things, I need to group working time records by day & then add sales on in a later query. Clearly if there was a record for each staff member for every day whetehr they work or not, all sales would be correctly attributed but I'd like to avoid having to create a table full of zero values for 3000 staff if I can. I have created a 'calendar' table with all dates in but that still doesn't seem to work. The SQL I'm using is as follows -
PARAMETERS [Forms]![Productivity_Dates]![DateFrom] DateTime, [Forms]![Productivity_Dates]![DateTo] DateTime;
TRANSFORM IIf(Sum([Tbl_TCS (Total)]![Minutes]) Is Null,0,Sum([Tbl_TCS (Total)]![Minutes])) AS Minutes
SELECT [Tbl_TCS (Total)].[Staff ID], [Tbl_TCS (Total)].[Data Date]
FROM Tbl_Calendar LEFT JOIN [Tbl_TCS (Total)] ON Tbl_Calendar.Date = [Tbl_TCS (Total)].[Data Date]
WHERE ((([Tbl_TCS (Total)].[Data Date]) Between [Forms]![Productivity_Dates]![DateFrom] And [Forms]![Productivity_Dates]![DateTo]))
GROUP BY [Tbl_TCS (Total)].[Staff ID], [Tbl_TCS (Total)].[Data Date]
PIVOT [Tbl_TCS (Total)].[Work Code];
Anyone give me a pointer (as you'll have guessed I'm a bit of a newbie at this) as to how I can get my crosstab to enter a date then zero values for each day in the range for each member of staff ?
[Tbl_TCS (Total)] is where all of the working time data is held with [Staff ID] being the person [Work Code] being what they're actually doing (several different types of work) & [Minutes] for how long on each day ([Data Date])
Thanks
Steve