Since I am not sure how you calculate the YTD column, My script does not include it:
DECLARE @StartDate date;
DECLARE @EndDate date;
SELECT @StartDate = MIN([Month]), @EndDate = MAX([Month]) FROM #Test
;WITH CTE_Date AS (
SELECT @StartDate AS [Month]
UNION ALL
SELECT DATEADD(MONTH, 1, [Month]) AS [Month]
FROM CTE_Date
WHERE [Month] < @EndDate
),
CTE_Distinct_C1_And_Region AS (
SELECT DISTINCT C1, Region
FROM #Test
),
CTE_Date_C1_Region AS (
SELECT [Month], C1, Region
FROM CTE_Date, CTE_Distinct_C1_And_Region
)
SELECT
CASE
WHEN t.FiscalYear IS NULL THEN
CASE WHEN MONTH(c.[Month]) >= 9 THEN YEAR(c.[Month]) + 1 ELSE YEAR(c.[Month]) END
ELSE t.FiscalYear
END AS FiscalYear,
c.[Month],
c.Region,
c.C1,
ISNULL(t.MTD, 0) AS MTD
FROM CTE_Date_C1_Region AS c
LEFT JOIN #Test AS t ON c.[Month] = t.[Month] AND c.Region = t.Region AND c.C1 = t.C1
ORDER BY c.[Month], c.[C1], c.[Region];