Forum Discussion
How to get weekdays from a date range
- 3 years ago
= List.Transform({Number.From([StartDate])..Number.From([EndDate)},each Date.DayOfWeekName(Date.From(_)))
HI stampedeadam ,
Please I have implemented the same question and also got the expected output.
Here is the M Code for the same:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDWNzTUNzIwMlbSAXPMIJxYHYicOZKckQlULhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Start Date" = _t, #"End Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Start Date", type date}, {"End Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "AllDates", each let
alldateinnumber = {Number.From([Start Date])..Number.From([End Date])},
alldateindate = List.Transform(alldateinnumber,each Date.From(_))
in
alldateindate),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "AllDates"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"AllDates", type date}}),
#"Added Custom1" = Table.AddColumn(#"Changed Type1", "WeekDay", each Date.DayOfWeekName([AllDates]))
in
#"Added Custom1"
Please refer the below image for better understanding:
I hope this will solve your problem and if you face any difficulties then please let me know.
And if this helps you then give it a kudos and accept it as a solution.
Thank you,
KeyurPatel