NorthwindDash<\/a><\/p>\nYour presence helped to make this event a great success. We wish you all the best and hope that you continue to be engaged with the Access User Group. Stay tuned for upcoming events by visiting accessusergroups.org.<\/p>\n
NOTE: You can see the stored procedure by restoring the database in the zip file NorthwindDash above, but if you just want to see the stored procedure here it is:<\/p>\n
USE [NorthwindDash]\r\nGO\r\n\/****** Object: StoredProcedure [dbo].[usp_Dashboard] Script Date: 8\/14\/2015 8:08:56 AM ******\/\r\nSET ANSI_NULLS ON\r\nGO\r\nSET QUOTED_IDENTIFIER ON\r\nGO\r\n-- =============================================\r\n-- Author: Juan Soto\r\n-- Create date: November 17th, 2014\r\n-- Description: Create table for Dashboard\r\n-- =============================================\r\nALTER PROCEDURE [dbo].[usp_Dashboard] \r\n -- Add the parameters for the stored procedure here\r\n @UserStartDate DateTime\r\nAS\r\nBEGIN\r\n\r\n -- SET NOCOUNT ON added to prevent extra result sets from\r\n -- interfering with SELECT statements.\r\n SET NOCOUNT ON;\r\n\r\n Declare @Dashboard Table\r\n (\r\n myMetric VarChar(50),\r\n myTimeFrame VarChar(50),\r\n Qty Money\r\n )\r\n\r\n DECLARE @StartDate DateTime\r\n DECLARE @EndDate DateTime\r\n\r\n DECLARE @Year DATE \r\n DECLARE @Quarter INT\r\n\r\n\r\n DECLARE @QuarterStartDate DateTime\r\n DECLARE @QuarterEndDate DateTime\r\n\r\n -- User supplies dates for analysis\r\n --Set @UserStartDate = CONVERT(DATETIME, '2014-11-08 00:00:00', 102)\r\n\r\n SET DATEFIRST 1; -- We want Monday as first weekday\r\n\r\n SELECT @StartDate= DATEADD(dd, -(DATEPART(dw, @UserStartDate )-1), @UserStartDate ) ;\r\n SELECT @EndDate= DATEADD(dd, 7-(DATEPART(dw, @UserStartDate )), @UserStartDate ) ;\r\n\r\n -- Calculation Quarters\r\n set @Year = DATEADD(day,-day(@userstartdate) + 1 ,@userstartdate)\r\n set @Year = dateadd(month, -month(@year)+1 ,@year)\r\n\r\n set @Quarter = datepart(quarter,@Userstartdate)\r\n\r\n set @QuarterStartDate =DATEADD(QUARTER, @Quarter - 1, @Year) \r\n\r\n set @QuarterEndDate = DATEADD(DAY, -1, DATEADD(QUARTER, @Quarter, @Year))\r\n \r\n --Calc customers created today\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'New Customers', 'Today', COUNT(ID) AS Qty\r\n FROM Customers\r\n WHERE DateCreated = @StartDate\r\n\r\n --Calc customers created this week\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'New Customers', 'ThisWeek', COUNT(ID) AS Qty\r\n FROM Customers\r\n WHERE (DateCreated BETWEEN @StartDate and @EndDate);\r\n\r\n\r\n --Calc customers created this month\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'New Customers', 'ThisMonth', COUNT(ID) AS Qty\r\n FROM Customers\r\n where (month(datecreated) = month(@UserStartDate) and year(datecreated) = year(@UserStartDate) )\r\n\r\n\r\n --Calc customers created this quarter\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'New Customers', 'ThisQtr', COUNT(ID) AS Qty\r\n FROM Customers\r\n WHERE (DateCreated BETWEEN @QuarterStartDate AND @QuarterEndDate)\r\n\r\n\r\n --Calc customers created this year\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'New Customers', 'ThisYear', COUNT(ID) AS Qty\r\n FROM Customers\r\n WHERE (year(DateCreated) = year(@UserstartDate) )\r\n\r\n --Calc orders created today\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'New Orders', 'Today', COUNT([Order ID]) AS Qty\r\n FROM Orders\r\n WHERE [Order Date] = @UserStartDate;\r\n\r\n --Calc Orders created this week\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'New Orders', 'ThisWeek', COUNT([Order ID]) AS Qty\r\n FROM Orders\r\n WHERE ([Order Date] BETWEEN @StartDate and @EndDate);\r\n\r\n\r\n --Calc Orders created this month\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'New Orders', 'ThisMonth', COUNT([Order ID]) AS Qty\r\n FROM Orders\r\n where (month([Order Date]) = month(@UserStartDate) and year([Order Date]) = year(@UserStartDate) )\r\n\r\n --Calc Orders created this quarter\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'New Orders', 'ThisQtr', COUNT([Order ID]) AS Qty\r\n FROM Orders\r\n WHERE ([Order Date] BETWEEN @QuarterStartDate AND @QuarterEndDate)\r\n\r\n --Calc Orders created this year\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'New Orders', 'ThisYear', COUNT([Order ID]) AS Qty\r\n FROM Orders\r\n WHERE (year([Order Date]) = year(@UserstartDate) )\r\n\r\n --Calc order dollars created today\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'Order$','Today',SUM([Order Summary].[Order Total]) AS Total\r\n FROM [Order Summary] INNER JOIN\r\n Orders ON [Order Summary].[Order ID] = Orders.[Order ID]\r\n WHERE Orders.[Paid Date] = @UserStartDate\r\n\r\n --Calc order dollars created this week\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'Order$','ThisWeek',SUM([Order Summary].[Order Total]) AS Total\r\n FROM [Order Summary] INNER JOIN\r\n Orders ON [Order Summary].[Order ID] = Orders.[Order ID]\r\n WHERE (Orders.[Paid Date] BETWEEN @StartDate and @EndDate);\r\n\r\n --Calc order dollars created this month\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'Order$','ThisMonth',SUM([Order Summary].[Order Total]) AS Total\r\n FROM [Order Summary] INNER JOIN\r\n Orders ON [Order Summary].[Order ID] = Orders.[Order ID]\r\n where (month(Orders.[Paid Date]) = month(@UserStartDate) and year(Orders.[Paid Date]) = year(@UserStartDate) )\r\n\r\n --Calc order dollars created this quarter\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'Order$','ThisQtr',SUM([Order Summary].[Order Total]) AS Total\r\n FROM [Order Summary] INNER JOIN\r\n Orders ON [Order Summary].[Order ID] = Orders.[Order ID]\r\n WHERE (Orders.[Paid Date] BETWEEN @QuarterStartDate AND @QuarterEndDate)\r\n\r\n --Calc order dollars created this year\r\n Insert Into @Dashboard(myMetric, myTimeFrame, Qty)\r\n SELECT 'Order$','ThisYear',SUM([Order Summary].[Order Total]) AS Total\r\n FROM [Order Summary] INNER JOIN\r\n Orders ON [Order Summary].[Order ID] = Orders.[Order ID]\r\n WHERE (year(orders.[Paid Date]) = year(@UserstartDate) )\r\n\r\n Select * from @Dashboard\r\n\r\nEnd<\/pre>\n","protected":false},"excerpt":{"rendered":"Congratulations Juan Soto on a great presentation this month! \u00a0I also want to thank everyone who joined the meeting and\u00a0hope that you found the webinar\u00a0informative and worthwhile. The video is now available for you to review: Here are the dashboard files:\u00a0NorthwindDash Your presence helped to make this event a great success. We wish you all […]<\/p>\n","protected":false},"author":103,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"mc4wp_mailchimp_campaign":[],"footnotes":""},"categories":[1],"tags":[],"yoast_head":"\n
Creating Dashboards in Microsoft Access - SQL Server with Access - AccessUserGroups.org<\/title>\n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n\t \n\t \n\t \n