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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
AlineTCarvalho
New Member

CALENDARAUTO

Hello

 

I am trying to create a dCALENDAR with CALENDARAUTO, and my fiscal year starts in April, therefore April should be Q1 for instance.

However when I use the QUARTER function, power bi understands calendar year (jan - dec).
Please can someone help me and see what I am doing wrong?

I appreciate your help 😃

DAX:

Calendarauto Data =

VAR MinYear = YEAR(MIN(fLedger[Posting Date]))

VAR MaxYear = YEAR(MAX(fLedger[Posting Date]))

 

 

 RETURN

ADDCOLUMNS(

    FILTER(

        CALENDARAUTO(3),

        YEAR ([Date]) >= MinYear &&

        YEAR ([Date]) <= MaxYear

    ),

 

    "Year", YEAR([Date]),

    "Quarter", "Q" & QUARTER([Date]))



AlineTCarvalho_0-1712680502297.png

 




3 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@AlineTCarvalho You can potentially use this fiscal calendar: DAX Custom 445 Calendar - Microsoft Fabric Community

 

Otherwise, Melissa de Korte's Power Query function for creating calendar tables is probably a good bet. Extended Date Table Power Query M Function | Master Data Skills + AI (enterprisedna.co)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

lbendlin
Super User
Super User

"Quarter""Q" & QUARTER(EDATE([Date],3)))

View solution in original post

v-tianyich-msft
Community Support
Community Support

Hi @AlineTCarvalho ,

 

Thank @lbendlin  very much for his solution! But there is a small error, it should be "Quarter""Q" & QUARTER(EDATE([Date],-3))). On that basis, I can give you a more complete date table, which can be seen in the following results:

vtianyichmsft_0-1712736224550.png

DimDate = 
ADDCOLUMNS (
    CALENDARAUTO (),
    "Year", YEAR ( [Date] ),
    "Month", FORMAT ( [Date], "MMMM" ),
    "MonthSort", MONTH ( [Date] ),
    "Day", DAY ( [Date] ),
    "DayName", FORMAT ( [Date], "DDDD" ),
    "WeekDay", WEEKDAY ( [Date],2 ),
    "WeekStart",
        [Date] - WEEKDAY ( [Date], 2 ) + 1,
    "Quarter", "Q" & QUARTER(EDATE([Date],-3))
)

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-tianyich-msft
Community Support
Community Support

Hi @AlineTCarvalho ,

 

Thank @lbendlin  very much for his solution! But there is a small error, it should be "Quarter""Q" & QUARTER(EDATE([Date],-3))). On that basis, I can give you a more complete date table, which can be seen in the following results:

vtianyichmsft_0-1712736224550.png

DimDate = 
ADDCOLUMNS (
    CALENDARAUTO (),
    "Year", YEAR ( [Date] ),
    "Month", FORMAT ( [Date], "MMMM" ),
    "MonthSort", MONTH ( [Date] ),
    "Day", DAY ( [Date] ),
    "DayName", FORMAT ( [Date], "DDDD" ),
    "WeekDay", WEEKDAY ( [Date],2 ),
    "WeekStart",
        [Date] - WEEKDAY ( [Date], 2 ) + 1,
    "Quarter", "Q" & QUARTER(EDATE([Date],-3))
)

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Thank you! I figured that because I wasn't getting the result right. 

I really aprreciate your input! 

lbendlin
Super User
Super User

"Quarter""Q" & QUARTER(EDATE([Date],3)))

Hi @lb_rlb brilliant, easy way to fix it.

Thank you so much for your help!

this is how it turned out:

Calendarauto Data =
VAR MinYear = YEAR(MIN(fLedger[Posting Date]))
VAR MaxYear = YEAR(MAX(fLedger[Posting Date]))
 
 
 RETURN
ADDCOLUMNS(
    FILTER(
        CALENDARAUTO(3),
        YEAR ([Date]) >= MinYear &&
        YEAR ([Date]) <= MaxYear
    ),
 
    "Year", YEAR([Date]),
    "Quarter", QUARTER(EDATE([Date],-3)))
Greg_Deckler
Super User
Super User

@AlineTCarvalho You can potentially use this fiscal calendar: DAX Custom 445 Calendar - Microsoft Fabric Community

 

Otherwise, Melissa de Korte's Power Query function for creating calendar tables is probably a good bet. Extended Date Table Power Query M Function | Master Data Skills + AI (enterprisedna.co)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hey, Greg!
Thank you so much. Your solution has helped me to figure this out.

 

This how it turned out:

Calendarauto segundo teste =

VAR MinYear = YEAR(MIN(fLedger[Posting Date]))

VAR MaxYear = YEAR(MAX(fLedger[Posting Date]))

 

 

 RETURN

 ADDCOLUMNS(

 ADDCOLUMNS(

 ADDCOLUMNS(

 ADDCOLUMNS(

ADDCOLUMNS(

    FILTER(

        CALENDARAUTO(),

        YEAR ([Date]) >= MinYear &&

        YEAR ([Date]) <= MaxYear

    ),

 

    "Year", YEAR([Date]),

    "Quarter CY", QUARTER([Date])),

 

    "QUARTER FY",

    SWITCH(TRUE(),

    QUARTER([Date]) = 1,"Q4",

    QUARTER([Date]) = 2,"Q1",

    QUARTER([Date]) = 3,"Q2",

    QUARTER([Date]) = 4,"Q3")),

 

    "FISCAL YEAR",

    SWITCH(TRUE(),

    [Date] >= DATE(2020,04,1) && [Date] <= DATE(2021,03,30),"FY2021",

    [Date] >= DATE(2021,04,1) && [Date] <= DATE(2022,03,30),"FY2122",

    [Date] >= DATE(2022,04,1) && [Date] <= DATE(2023,03,30),"FY2223",

    [Date] >= DATE(2023,04,1) && [Date] <= DATE(2024,03,30),"FY2324",

    [Date] >= DATE(2024,04,1) && [Date] <= DATE(2025,03,30),"FY2425")),

 

   

    "FY'Q",

    LEFT([FISCAL YEAR],4) &"'"& [QUARTER FY]),

 

    "Month Year",

    FORMAT([Date],"mmm")&"/"&

    FORMAT([Date],"yy"))



Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.