Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
100 | |
78 | |
76 | |
52 |
User | Count |
---|---|
144 | |
109 | |
108 | |
88 | |
61 |