Here is my current code (minus what you added). Clearly I am doing more than what I shared with you and I am sure that is where the issue lies.
I basically start with an input table for people that have almost 0 Excel experience to update. It only has these columns
Budget ID | Project Name | Renamed | Division/Department | Project Manager | Spending Geometry | Status | Est. Start Date | Est. End Date
|
<tbody>
</tbody>
Funny you mentioned Marcel because some of his code is in here. What I am trying to do is format this data so that I can get it into a pivot table and show spend by month for the next 5 or so years (I can handle that, getting the format is my problem).
I used a portion of Marcel's code to say if a project is 3 months long create one line for each month (really just months remaining).
So the project name (project A as we have been referencing has 3 months remaining (April, May, & June).
I created the 3 lines in hopes that I could then get a count of each line and add months based on the count (Hopefully that makes sense). So for Project A line 2 I was going to add 2 months to our current month and make that the budget line for May, for line 3 I was going to add 3 months and make that our budget line for June.
As mentioned I got your code to run but it groups everything to 1 line and does not ungroup it back. 100% positive it is user error.
let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Budget ID", type any}, {"Project Name", type text}, {"Renamed", type text}, {"Division/Department", type text}, {"Project Manager", type text}, {"Spending Geometry", type text}, {"Status", type text}, {"Est. Start Date", type date}, {"Est. End Date", type date}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Spending Geometry] = "Linear") and ([Status] = "Deferred" or [Status] = "Future" or [Status] = "In Progress")),
#"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Est. Start Date", Order.Ascending}}),
#"Months Between" = Table.AddColumn(#"Sorted Rows", "Duration", each ([Est. End Date]-[Est. Start Date])/30.5),
#"Changed Type1" = Table.TransformColumnTypes(#"Months Between",{{"Duration", Int64.Type}}),
#"Todays Date" = Table.AddColumn(#"Changed Type1", "Today's Date", each DateTime.LocalNow()),
#"Changed Type2" = Table.TransformColumnTypes(#"Todays Date",{{"Today's Date", type date}}),
#"Months Remaining" = Table.AddColumn(#"Changed Type2", "Months Remaining", each ([Est. End Date]-[#"Today's Date"])/30.5),
#"Changed Type3" = Table.TransformColumnTypes(#"Months Remaining",{{"Months Remaining", Int64.Type}}),
#"Percentage Complete" = Table.AddColumn(#"Changed Type3", "Percentage Complete", each 1-([Months Remaining]/[Duration])),
#"Added Custom" = Table.AddColumn(#"Percentage Complete", "Percent Complete", each if[Percentage Complete]<0 then 0 else [Percentage Complete]),
#"Changed Type4" = Table.TransformColumnTypes(#"Added Custom",{{"Percent Complete", Percentage.Type}}),
#"Rounded Off" = Table.TransformColumns(#"Changed Type4",{{"Percent Complete", each Number.Round(_, 2), Percentage.Type}}),
#"Removed Columns" = Table.RemoveColumns(#"Rounded Off",{"Percentage Complete"}),
#"Filtered Rows1" = Table.SelectRows(#"Removed Columns", each [Months Remaining] > 0),
#"Repeated" = Table.TransformColumns(#"Filtered Rows1", {"Months Remaining", each List.Numbers(_,_,0), type list}),
#"Expanded" = Table.ExpandListColumn(Repeated, "Months Remaining")
in
Expanded