Scenario:
Let's say we have two date columns in a Dataset as Task_Start_Date and Task_End_Date as shown below.
For example, Task_Start_Date = 01-Jan-2021 and Task_End_Date= 05-Jan-2021, then there are 5 no. of dates falls between those dates (inclusive of Start and End Dates).
We can achieve this Scenario, using the below Power Query logic:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddDLCQAhDATQXnJ2IYn/WsT+23DZuYwLAS/jk4m6lqg973J1kyRaKZjs9PdGweHOPilkeI76C7xEXuE16m9wvpIphQ7v7PyYAR9R/4Tzll3/o9+Ba6aVa5rsfQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Task_Start_Date = _t, Task_End_Date = _t, Task_Owner_ID = _t]),ChangeType = Table.TransformColumnTypes(Source,{{"Task_Start_Date", type date}, {"Task_End_Date", type date}, {"Task_Owner_ID", Int64.Type}}),
TaskActiveDates =
Table.AddColumn(ChangeType, "Task_Active_Dates",
each List.Dates(
Table.AddColumn(ChangeType, "Task_Active_Dates",
each List.Dates(
[Task_Start_Date],
Duration.Days([Task_End_Date]-[Task_Start_Date])+1,
#duration(1,0,0,0)
)),
ExpandDates = Table.ExpandListColumn(TaskActiveDates, "Task_Active_Dates")
in
ExpandDates
Result:
No comments:
Post a Comment
Hi User, Thank You for visiting My Blog. If you wish, please share your genuine Feedback or comments only related to this Blog Posts. It is my humble request that, please do not post any Spam comments or Advertising kind of comments, which will be Ignored.