Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
I have Week/Year in a column and would like to convert into Friday of the week.
Example:
wk31/2021 should return 06/Aug/20201
wk31/2021 shuld return 13/Aug/2021
I need this is Power Query only.
Thanks for your help in advance.
@Greg_Deckler Thanks and solution works perfectly for 2021 but 2022 dates are not for friday, see below:
Any suggestion please?
@mb0307 Well, they were for Friday, just the wrong Friday. Slight error, see if this one is better and if you can see the difference:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjbUNzIwMlSK1QGyjRBssLARmGkBZcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", Int64.Type}, {"Column1.2", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Date.AddWeeks(#date([Column1.2],1,1),[Column1.1]-1)),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Date.EndOfWeek([Custom],Day.Saturday)),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Column1.1", "Column1.2", "Custom"})
in
#"Removed Columns"
@mb0307 Try:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjbUNzIwMlSK1QGyjaDsWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", Int64.Type}, {"Column1.2", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Date.AddWeeks(#date([Column1.2],1,1),[Column1.1])),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Date.EndOfWeek([Custom],Day.Saturday)),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Column1.1", "Column1.2", "Custom"})
in
#"Removed Columns"
User | Count |
---|---|
128 | |
109 | |
100 | |
65 | |
62 |
User | Count |
---|---|
137 | |
115 | |
102 | |
71 | |
61 |