Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

"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...
  • danextian's avatar
    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"