Forum Discussion
Anonymous
2 years agoNot applicable
"Fill in" values between dates
Ran into an issue similar to This Question , I am doing something very similar but instead need much more resolution for the dates. What I have is the following starting table: Ticket Status...
- 2 years ago
Hi Anonymous ,
It seemst that what you want is to continue fill-in the date in between the status and still continue filling in the dates up to current even if the status is already one. If so, try this (filtered to ABC123 only).
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyNjQyVtJR8sxTCCjKTy9KLS4G8gxM9Q1M9I0MgFKxOkiqXPLzUqHS5ghpF1c3E1MzrIaYIlT5+PpZWphjVQUzKxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ticket = _t, Status = _t, Date = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Ticket", type text}, {"Status", type text}}), #"Changed Type with Locale" = Table.TransformColumnTypes(#"Changed Type", {{"Date", type date}}, "en-US"), #"Grouped Rows" = Table.Group(#"Changed Type with Locale", {"Ticket"}, {{"Group", each _, type table [Ticket=nullable text, Status=nullable text, Date=nullable date]}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "DoneDate", each try Table.SelectRows([Group], each [Status] = "Done")[Date]{0} otherwise Date.From(DateTimeZone.LocalNow()), type date), #"Expanded Group" = Table.ExpandTableColumn(#"Added Custom", "Group", {"Ticket", "Status", "Date"}, {"Ticket.1", "Status", "Date"}), #"Filtered Rows" = Table.SelectRows(#"Expanded Group", each [Ticket] = "ABC123"), #"Added Custom1" = Table.AddColumn(#"Filtered Rows", "Dates", each let donedate = [DoneDate], maxdate = if [Status] = "Done" then Date.From(DateTime.LocalNow()) else Date.AddDays(donedate, -1), count = Duration.Days(maxdate-[Date]) + 1 in List.Dates([Date], count, #duration(1,0,0,0)) , type list), #"Expanded Dates" = Table.ExpandListColumn(#"Added Custom1", "Dates"), #"Changed Type2" = Table.TransformColumnTypes(#"Expanded Dates",{{"Dates", type date}}), #"Changed Type1" = Table.TransformColumnTypes(#"Changed Type2",{{"Dates", type date}}) in #"Changed Type1"
ppm1
Solution Sage
2 years agoIf you have only 1 or 2 rows per ticket, here's one way to do it in the query editor. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyNjQyVtJR8sxTCCjKTy9KLS4G8kz1TfSNDIASsTpIalzy81LBkuYISRdXNxNTMywGmCLU+Pj6WVqYY1EDMycWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ticket = _t, Status = _t, Date = _t]),
#"Pivoted Column" = Table.Pivot(Source, List.Distinct(Source[Status]), "Status", "Date"),
#"Replaced Value" = Table.ReplaceValue(#"Pivoted Column",null,Date.From(DateTime.LocalNow()),Replacer.ReplaceValue,{"Done"}),
#"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Done", type date}, {"In Progress", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Date", each List.Transform({Number.From([In Progress])..Number.From([Done])}, each Date.From(_) )),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Ticket", "Date"}),
#"Expanded Date" = Table.ExpandListColumn(#"Removed Other Columns", "Date"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Date",{{"Date", type date}})
in
#"Changed Type1"
Pat