Forum Discussion
Broken Year
If the customer's calendar year is from Oct to next year's Sep, then it should be "When MONTH(@LoopDate)<10". How are visuals not working with the broken calendar? Do they work after fixxing "When MONTH(@LoopDate)<10"?
Thanks,
I how now tested the new script but when I look to the result in the table I see that only the last column is right FiscalQuarter for october is 1, but the column Date_CalenderQuarter is 4
Here is the script I used
Use [Power BI]
Declare @StartDate datetime
Declare @EndDate datetime
Set @StartDate = '2006-10-01'
Set @EndDate = GETDATE()
Declare @LoopDate datetime
Set @LoopDate = @StartDate
While @LoopDate <= @EndDate
Begin
Insert Into dbo.DimDate Values
(
Cast(Convert(Varchar(8), @LoopDate, 112) AS Int),
@LoopDate,
YEAR(@LoopDate),
DATEPART(qq, @LoopDate),
MONTH(@LoopDate),
DATENAME(mm, @LoopDate),
DAY(@LoopDate),
DATEPART(DW, @LoopDate),
DATENAME(DW, @LoopDate),
Case
When MONTH(@LoopDate)<1 Then YEAR(@LoopDate)
Else YEAR(@LoopDate) +1
End,
Case
When MONTH(@LoopDate) IN (10, 11, 12) Then 1
When MONTH(@LoopDate) IN (1, 2, 3) Then 2
When MONTH(@LoopDate) IN (4, 5, 6) Then 3
When MONTH(@LoopDate) IN (7, 8, 9) Then 4
End
)
SET @LoopDate = DATEADD(dd, 1, @LoopDate)
End;
- Eric_Zhang10 years agoMicrosoft Employee
What is the problem with Date_CalenderQuarter being 4? October should be in Quarter 4 in a nature year.