Forum Discussion
Anonymous
3 years agoNot applicable
Getting all dates between 2 dates excluding weekends
Hello, I found this https://community.powerbi.com/t5/Desktop/Getting-all-dates-between-2-dates/m-p/60577/page/2 post, its works however when I wanna apply changes, it says that its not supported...
Anonymous
3 years agoNot applicable
Hi Anonymous ,
Please refer to my pbix file to see if it helps you.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwNNM31jcyVNKBs82UYnWgMqb6pjAJU31zqLiRkb6hob6hAVgGwjEyVYqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [startdate = _t, enddate = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"startdate", type date}, {"enddate", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each { Number.From([#"startdate"])..Number.From([#"enddate"]) }),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type date}}),
#"Added Custom1" = Table.AddColumn(#"Changed Type1", "Custom.1", each Date.DayOfWeek([Custom],Day.Monday)),
#"Added Conditional Column" = Table.AddColumn(#"Added Custom1", "Custom.2", each if [Custom.1] >= 5 then "" else [Custom]),
#"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"Custom", "Custom.1"})
in
#"Removed Columns"
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.