SQL View to Return Budget Amounts by Accounting Period in Microsoft Dynamics 365 Business Central

Microsoft Dynamics 365 Business CentralI posted a SQL view towards the end of January which returns the start and end date of accounting periods in Microsoft Dynamics 365 Business Central.

The SQL view below uses that view to return the budget figures from Dynamics BC for each accounting period grouped by account and the global and budget dimensions.

-- drop view if it exists
IF OBJECT_ID(N'uv_AZRCRV_BudgetAmountByAccountingPeriod', N'V') IS NOT NULL
	DROP VIEW uv_AZRCRV_BudgetAmountByAccountingPeriod
GO
-- create view
CREATE VIEW uv_AZRCRV_BudgetAmountByAccountingPeriod AS
/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
SELECT ['G/L Budget Entry'].[Budget Name] ,['G/L Budget Entry'].[G_L Account No_] ,[Accounting Periods].[Starting Date] ,[Accounting Periods].[Ending Date] ,[Accounting Periods].[Name] ,['G/L Budget Entry'].[Global Dimension 1 Code] ,['G/L Budget Entry'].[Global Dimension 2 Code] ,['G/L Budget Entry'].[Budget Dimension 1 Code] ,['G/L Budget Entry'].[Budget Dimension 2 Code] ,['G/L Budget Entry'].[Budget Dimension 3 Code] ,['G/L Budget Entry'].[Budget Dimension 4 Code] ,SUM(['G/L Budget Entry'].Amount) AS [Budget Amount] FROM [CRONUS UK Ltd_$G_L Budget Entry$437dbf0e-84ff-417a-965d-ed2bb9650972] AS ['G/L Budget Entry'] INNER JOIN uv_AZRCRV_GetAccountingPeriodDates AS [Accounting Periods] ON ['G/L Budget Entry'].[Date] BETWEEN [Accounting Periods].[Starting Date] AND [Accounting Periods].[Ending Date] GROUP BY ['G/L Budget Entry'].[Budget Name] ,['G/L Budget Entry'].[G_L Account No_] ,[Accounting Periods].[Starting Date] ,[Accounting Periods].[Ending Date] ,[Accounting Periods].[Name] ,['G/L Budget Entry'].[Global Dimension 1 Code] ,['G/L Budget Entry'].[Global Dimension 2 Code] ,['G/L Budget Entry'].[Budget Dimension 1 Code] ,['G/L Budget Entry'].[Budget Dimension 2 Code] ,['G/L Budget Entry'].[Budget Dimension 3 Code] ,['G/L Budget Entry'].[Budget Dimension 4 Code] ORDER BY [Accounting Periods].[Starting Date] GO GRANT SELECT ON uv_AZRCRV_BudgetAmountByAccountingPeriod TO [Reporting Users] GO

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

Leave a Reply

Your email address will not be published. Required fields are marked *