Reputation: 11
New to PowerBi and Power Query and having some trouble transforming the data.
The data contains processes for each sale category with status if the manufacturing process has been complete or not. Require a new aggregate table that has three calculated columns returning the following dates:
Have managed to return the three dates but each ends up on a separate line rather than one line with the data. Below is the original data and required output.
Would appreciate any assistance in transforming this data.
Upvotes: 1
Views: 183
Reputation: 60389
Most of it you can do using the Power Query UI:
Month/Category/Process
But then you need a custom aggregation where you determine the max date after filtering the subtable for "Done" in the status column.
You can do that in the Advanced Editor editing the M Code directly.
M Code
let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Month", type date},
{"Category", type text}, {"Process", type text}, {"Status", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Month", "Category", "Process"}, {
{"Start Date", each List.Min([Date]), type nullable date},
{"Predicted End Date", each List.Max([Date]), type nullable date},
//Custom aggregation to calculate Actual End Date
//Note that we can Filter the table here, and then select the last date
{"Actual End Date", each List.Max(Table.SelectRows(_, each [Status]= "Done")[Date]), type nullable date}
})
in
#"Grouped Rows"
Original Data
Results
Upvotes: 1