• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Power Query Date Week Of Year

e103050_1

New Member
I have created a column in a power query that returns the week number of dates with week start day of Friday using the following;

= Table.AddColumn(#"Inserted Week of Year RFT", "W_RFT", each Date.WeekOfYear([RFT],Day.Friday), Int64.Type)

and another column for year;

= Table.AddColumn(#"Inserted Week of Year RFT", "Year", each Date.Year([START FAB]), Int64.Type)

but I need to a week column with the format of "Year_WeekNumber" like "2020_19"
I need a function like an excel formula "=YEAR(BC2)&"_"&WEEKNUM(BC2,15)"
target table as below;
anyone hep me to create function in excel power query?

1638951699001.png



RFTWeek
5/19/20212021_20
2/3/20212021_5
5/20/20212021_20
2/3/20212021_5
7/18/20212021_29
3/24/20212021_12
3/24/20212021_12
3/24/20212021_12
3/24/20212021_12

any idea?
 
Both columns in PQ need to be text. Then you combine them.
Sidenote: consider PQ does not return weeknumber according to ISO standards. In Europe that might be an issue.
 
e103050_1
... as well as You should reread Forum Rules
There are clear sentences, if someone uses Cross-Posting.
 
Answered in this link

Sorry for fergetting providing cross post link

Code:
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"RFT", type date}}),
    #"Inserted Year" = Table.AddColumn(#"Changed Type", "Year", each Date.Year([RFT]), Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Inserted Year", "Custom", each Date.WeekOfYear([RFT],Day.Friday)),
    #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Added Custom", {{"Year", type text}, {"Custom", type text}}, "en-US"),{"Year", "Custom"},Combiner.CombineTextByDelimiter("_", QuoteStyle.None),"Week")
in
    #"Merged Columns"
 
Back
Top