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
Libin7025
Frequent Visitor

Dynamic DAX for UTC to EDT (Daylight time) conversion.

Dynamic EDT&EST = VAR OriginalDateTime = src_system_info[loaded_at]
VAR CurrentYear = YEAR(TODAY())

// Calculate the second Sunday of March for the current year

VAR MarchFirst = DATE(CurrentYear, 3, 1)
VAR Weekdayofmarchfirst = WEEKDAY(MarchFirst)

VAR MarchSecondSunday =

SWITCH(
    true(),
    Weekdayofmarchfirst = 1, MarchFirst + (7 - Weekdayofmarchfirst) + 1,
    Weekdayofmarchfirst > 1, MarchFirst + (14 - Weekdayofmarchfirst) + 1
)

//Calculate the first sunday of November for current year
VAR NovemberFirst = Date(CurrentYear, 11, 1)
VAR NovemberFirstSunday = NovemberFirst + (7 - WEEKDAY(NovemberFirst)) + 1  

VAR EDTStart = MarchSecondSunday // Second Sunday of March
VAR ESTStart = NovemberFirstSunday // First Sunday of November

VAR AdjustedDateTime =
    SWITCH(
        TRUE(),
        OriginalDateTime >= EDTStart && OriginalDateTime < ESTStart,
        OriginalDateTime - TIME(4, 0, 0),  // Eastern Daylight Time (EDT) UTC offset is -4 hours

        OriginalDateTime >= ESTStart && OriginalDateTime < EDTStart + 365, // Transition occurs within a year
        OriginalDateTime - TIME(5, 0, 0),  // Eastern Standard Time (EST) UTC offset is -5 hours

        TRUE(),
        BLANK()
    )

RETURN
    FORMAT(AdjustedDateTime, "DD MMM YYYY") & " at " & FORMAT(AdjustedDateTime, "hh:mm:ss AM/PM") & IF(HOUR(AdjustedDateTime) = 0, " ET", " EDT")
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Libin7025 Is this a question or a post on a helpful DAX calculation? If the latter, you might consider posting it to the Quick Measures Gallery. Quick Measures Gallery - Microsoft Fabric Community


@ 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

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Libin7025 Is this a question or a post on a helpful DAX calculation? If the latter, you might consider posting it to the Quick Measures Gallery. Quick Measures Gallery - Microsoft Fabric Community


@ 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...

It's a helpful DAX calculation. Thanks for directing me to the right path to post this. 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors