Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
smiller
Frequent Visitor

Missing Quarter in calendar year

I have a calendar set up. 

Where October is my fiscal start: 

Fiscal Month = Month(edate(CalendarTable[Date],-9))
 
I have a date column
 CalendarTable = CALENDARAUTO(9)
 
and a quarter and month column
    Fiscal Quarter = "Q" & Quarter(edate(CalendarTable[Date],-9))
                Month = Format(CalendarTable[Date], "mmm")
 
I releated the fiscal calendar to my data on date to service_date many to 1 cardinality and singe on cross.
 
I have data for every quarter in 2023 in my source data; however Q1 does not show up on my visualizations, it does for 2022,20201, 2020 etc. I have no filters on accidently. The data columns are formatted the same way as short date. My data comes in via directquery from SQL server.  All the other years are fine? 
Also its grabbing years back to early 1900s? My direct query clearly has >=10-01-2020 for that date column, there are no other date columns in my query. 
 
 
 
 
1 ACCEPTED SOLUTION
NilR
Post Patron
Post Patron

 

Step One:

 

Date =
VAR MinYear = YEAR ( MIN ( Sales[Order Date] ) )
VAR MaxYear = YEAR ( MAX ( Sales[Order Date] ) )
RETURN
ADDCOLUMNS (
    FILTER (
        CALENDARAUTO( ),
        AND ( YEAR ( [Date] ) >= MinYear, YEAR ( [Date] ) <= MaxYear )
    ),
    "Calendar Year", "CY " & YEAR ( [Date] ),
    "Month Name", FORMAT ( [Date], "mmmm" ),
    "Month Number", MONTH ( [Date] ),
    "Weekday", FORMAT ( [Date], "dddd" ),
    "Weekday number", WEEKDAY( [Date] ),
    "Quarter", "Q" & TRUNC ( ( MONTH ( [Date] ) - 1 ) / 3 ) + 1
)

 

 

Step two:

 

Sales YTD 2 =
CALCULATE (
    [Sales Amount],
    VAR FirstFiscalMonth = 3 -- Set the first month of the fiscal year
    VAR LastDay =
        MAX ( 'Date'[Date] )
    VAR LastMonth =
        MONTH ( LastDay )
    VAR LastYear =
        YEAR ( LastDay )
            - IF ( LastMonth < FirstFiscalMonth, 1 )
    VAR FilterYtd =
        DATESBETWEEN (
            'Date'[Date],
            DATE ( LastYear, FirstFiscalMonth, 1 ),
            LastDay
        )
    RETURN
        FilterYtd
)

 

 

 

View solution in original post

9 REPLIES 9
smiller
Frequent Visitor

Thank you!!!!

Ashish_Mathur
Super User
Super User

Hi,

There is some problem with the Calendar Table.  One will have to work on the file to identify the reason.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
NilR
Post Patron
Post Patron

 

Step One:

 

Date =
VAR MinYear = YEAR ( MIN ( Sales[Order Date] ) )
VAR MaxYear = YEAR ( MAX ( Sales[Order Date] ) )
RETURN
ADDCOLUMNS (
    FILTER (
        CALENDARAUTO( ),
        AND ( YEAR ( [Date] ) >= MinYear, YEAR ( [Date] ) <= MaxYear )
    ),
    "Calendar Year", "CY " & YEAR ( [Date] ),
    "Month Name", FORMAT ( [Date], "mmmm" ),
    "Month Number", MONTH ( [Date] ),
    "Weekday", FORMAT ( [Date], "dddd" ),
    "Weekday number", WEEKDAY( [Date] ),
    "Quarter", "Q" & TRUNC ( ( MONTH ( [Date] ) - 1 ) / 3 ) + 1
)

 

 

Step two:

 

Sales YTD 2 =
CALCULATE (
    [Sales Amount],
    VAR FirstFiscalMonth = 3 -- Set the first month of the fiscal year
    VAR LastDay =
        MAX ( 'Date'[Date] )
    VAR LastMonth =
        MONTH ( LastDay )
    VAR LastYear =
        YEAR ( LastDay )
            - IF ( LastMonth < FirstFiscalMonth, 1 )
    VAR FilterYtd =
        DATESBETWEEN (
            'Date'[Date],
            DATE ( LastYear, FirstFiscalMonth, 1 ),
            LastDay
        )
    RETURN
        FilterYtd
)

 

 

 

smiller
Frequent Visitor

Thanks! Where steps 2 go? New column? New Measure? and what is [Sales_Amount]?

First is your Calendar table and second is your measure to calculate your values in your date range you need. 

smiller
Frequent Visitor

But what is [Sales_Amount]?

Any value you have, can be Just sum of your Sale, Count of orders, or Contract, or sum /count of something! Second step depends on what you might need or ignor if you don't. but based on your original question you only need the first step to create your calendar table.

smiller
Frequent Visitor

Yeah i dont necessarily need a measure to add anything up , but that calendar does not shift october to my first month of the calendar year?

ADD This column to your calendar!

 

Fiscal Year =
VAR FirstFiscalMonth = 9
RETURN
IF (
MONTH('Calendar Service'[Date]) >= FirstFiscalMonth,
YEAR('Calendar Service'[Date]) + 1,
YEAR('Calendar Service'[Date])
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.