MyTetra Share
Делитесь знаниями!
Неделя в Power Query2
Время создания: 15.01.2021 12:38
Текстовые метки: Power Query, WeekISO
Раздел: Разные закладки - MSO - Excel - Power Query
Запись: xintrea/mytetra_db_adgaver_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.65
Яндекс индекс цитирования