Forum Discussion
Daylight Savings Time
- 5 years ago
My apologies, we need to account for the context transition:
Offset = VAR currentYear_ = YEAR ( CalendarT[Date] ) VAR lastMarchSunday_ = CALCULATE ( MAX ( CalendarT[Date] ), MONTH ( CalendarT[Date] ) = 3, WEEKDAY ( CalendarT[Date], 2 ) = 7, YEAR ( CalendarT[Date] ) = currentYear_, ALL( CalendarT) ) VAR lastOctoberSunday_ = CALCULATE ( MAX ( CalendarT[Date] ), MONTH ( CalendarT[Date] ) = 10, WEEKDAY ( CalendarT[Date], 2 ) = 7, YEAR ( CalendarT[Date] ) = currentYear_, ALL( CalendarT) ) RETURN IF ( CalendarT[Date] >= lastMarchSunday_ && CalendarT[Date] < lastOctoberSunday_, 1, 0 )Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Hi msommerf
Add a calculated column to your calendar table CalendarT:
Offset =
VAR currentYear_ =
YEAR ( CalendarT[Date] )
VAR lastMarchSunday_ =
CALCULATE (
MAX ( CalendarT[Date] ),
MONTH ( CalendarT[Date] ) = 3,
WEEKDAY ( CalendarT[Date], 2 ) = 7,
YEAR ( CalendarT[Date] ) = currentYear_
)
VAR lastOctoberSunday_ =
CALCULATE (
MAX ( CalendarT[Date] ),
MONTH ( CalendarT[Date] ) = 10,
WEEKDAY ( CalendarT[Date], 2 ) = 7,
YEAR ( CalendarT[Date] ) = currentYear_
)
RETURN
IF (
CalendarT[Date] >= lastMarchSunday_
&& CalendarT[Date] < lastOctoberSunday_,
1,
0
)
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Thank you for responding so quickly.
When I use the supplied formula, I get a column of 0's with No 1's as follows:
- AlB5 years ago
Community Champion
My apologies, we need to account for the context transition:
Offset = VAR currentYear_ = YEAR ( CalendarT[Date] ) VAR lastMarchSunday_ = CALCULATE ( MAX ( CalendarT[Date] ), MONTH ( CalendarT[Date] ) = 3, WEEKDAY ( CalendarT[Date], 2 ) = 7, YEAR ( CalendarT[Date] ) = currentYear_, ALL( CalendarT) ) VAR lastOctoberSunday_ = CALCULATE ( MAX ( CalendarT[Date] ), MONTH ( CalendarT[Date] ) = 10, WEEKDAY ( CalendarT[Date], 2 ) = 7, YEAR ( CalendarT[Date] ) = currentYear_, ALL( CalendarT) ) RETURN IF ( CalendarT[Date] >= lastMarchSunday_ && CalendarT[Date] < lastOctoberSunday_, 1, 0 )Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
- msommerf5 years ago
Helper III
This is perfect.
Thank you so much for responding.
I just need to get my head around how this is doing the calculation, so that I may learn.
Kind regards
Mark.