Forum Discussion
How to create a Continuous custom Date Hierarchy?
- 6 years ago
Anonymous and pbit,
I asked a similar question in a comment thread on SQLBI. Link here: http://disq.us/p/28db3dz
Marco Russo responded with an answer, and it sounds like they're publishing an article about it soon. I'll paste his comment and example below. I hope this helps!
"Power BI uses an internal attribute (data category) that cannot be modified in Power BI.
You can obtain the same behavior by creating columns as dates and formatting them as you want. We will publish an article about this in a few weeks, the principle is using a calculated table like the one below and then set the custom format of the columns using strings as yyyy (year) and mmm yyyy (month year)..."Date =
VAR FirstFiscalMonth = 7 -- First month of fiscal year
VAR FirstDayOfWeek = 0 -- 0 = Sunday, 1 = Monday, ...
VAR FirstYear = -- Customize first year to use
YEAR ( MIN ( Sales[Order Date] ))
RETURN
GENERATE (
FILTER (
CALENDARAUTO (),
YEAR ( [Date] ) >= FirstYear
),
VAR Yr = YEAR ( [Date] ) -- Year Number
VAR Mn = MONTH ( [Date] ) -- Month Number (1-12)
VAR Qr = QUARTER ( [Date] ) + 1 -- Quarter Number (1-4)
VAR MnQ = Mn - 3 * (Qr - 1) -- Month in Quarter (1-3)
VAR Wd = WEEKDAY ( [Date], 1 ) - 1 -- Week day number (0 = Sunday, 1 = Monday, ...)
VAR Fyr = -- Fiscal Year Number
YEAR ( DATE ( Yr, Mn + FirstFiscalMonth - 1, 1 ) )
VAR Fqr = -- Fiscal Quarter (string)
FORMAT ( EOMONTH ( [Date], 1 - FirstFiscalMonth ), "\QQ" )
RETURN ROW (
"Year", DATE ( Yr, 12, 31 ),
"Year Quarter", FORMAT ( [Date], "\QQ-YYYY" ),
"Year Quarter Date", EOMONTH ( [Date], 3 - MnQ ),
"Quarter", FORMAT ( [Date], "\QQ" ),
"Year Month", EOMONTH ( [Date], 0 ),
"Month", DATE ( 1900, MONTH ( [Date] ), 1 ),
"Day of Week", DATE ( 1900, 1, 7 + Wd + (7 * (Wd < FirstDayOfWeek)) ),
"Fiscal Year", DATE ( Fyr, FirstFiscalMonth, 1 ) - 1,
"Fiscal Year Quarter", "F" & Fqr & "-" & Fyr,
"Fiscal Year Quarter Date", EOMONTH ( [Date], 3 - MnQ ),
"Fiscal Quarter", "F" & Fqr
)
)
Was a solution ever found for this?
I have still not found a solution. Have asked everywhere but no one seem to be aware of this, which is highly surprising as any Line Chart might be affected in an undesirable manner if the X-axis can't be set to Continuous.