MyTetra Share
Делитесь знаниями!
Неделя в Power Query2
Время создания: 15.01.2021 12:38
Текстовые метки: Power Query, WeekISO
Раздел: !Закладки - MSO - Excel - Power Query
Запись: adgaver/mytetra_base_New/master/base/1610703484vvkdkl1v9i/text.html на raw.githubusercontent.com

let

ISO8601Week = (Date as date) =>

let

AncillaryWeek = (Date as date) =>

let

WeekDay = 1 + Date.DayOfWeek(Date, Day.Monday),

OrdinalDay = Date.DayOfYear(Date),

AncillaryWeekNumber = Number.RoundDown((OrdinalDay - WeekDay + 10) / 7)

in

AncillaryWeekNumber,

ThisYear = Date.Year(Date),

PriorYear = ThisYear - 1,

AncillaryNumber = AncillaryWeek(Date),

LastWeekOfPriorYear = AncillaryWeek(#date(PriorYear, 12, 28)),

LastWeekOfThisYear = AncillaryWeek(#date(ThisYear, 12, 28)),

WeekNumber = if AncillaryNumber < 1 then LastWeekOfPriorYear else

if AncillaryNumber > LastWeekOfThisYear then 1 else AncillaryNumber

in

WeekNumber

in

ISO8601Week

 
MyTetra Share v.0.55
Яндекс индекс цитирования