Forum Discussion

yuval86's avatar
yuval86
Regular Visitor
9 years ago
Solved

convert week number into data

Hello,   I have a week number (1,2,...,52) and I have the year, I'm looking for a function that could transform\convert the week and the year into date. for some reason I didn't manage to do that....
  • ImkeF's avatar
    ImkeF
    9 years ago

     As I'm not aware of a function that returns the date of the week, instead I'd create a calendar for the year (replace "YourYear" respectively), create the week numbers and their first dates. Then filter on your week-numbers:

     

    let
        Source = {Number.From(#date(YourYear,01,01))..Number.From(#date(YourYear,12,31))},
        #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
        #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type date}}),
        WeekColumn = Table.AddColumn(#"Changed Type", "Week", each Date.WeekOfYear([Column1])),
        StartOfWeek = Table.AddColumn(WeekColumn, "StartOfWeek", each Date.StartOfWeek([Column1])),
        #"Filtered Rows1" = Table.SelectRows(StartOfWeek, each [Week] >= List.Min(YourWeekList) and [Week] <= List.Min(YourWeekList))
    in
        #"Filtered Rows1"