Forum Discussion

Otto_Luvpuppy's avatar
Otto_Luvpuppy
Helper II
6 years ago
Solved

Between Two Dates

Hi, I'm creating a Custom Column with some 'if else' bits going on. I'm nearly there but can't quite get the final piece. I need to select a particular line if it's date is bewteen two dates...one o...
  • Greg_Deckler's avatar
    Greg_Deckler
    6 years ago

    Otto_Luvpuppy - Well, error messages always help. So the biggest issue I see is that it looks like you are referring to a step as if it is a column but it is hard to tell. Try this query out and see how it matches up with yours:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtM30jcyMDJQ0gEyTSDMWJ1oBAckbowsbo4Qt0AWNzRASFhCJWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date of Return" = _t, #"Max Date" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date of Return", type date}, {"Max Date", type date}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Date of Return] > Date.FromText("1/1/1900") and [Date of Return] < [Max Date] then "Overdue" else "Not")
    in
        #"Added Custom"

     

    You can just create a blank query and then paste in this code, completely replacing the existing code in Advanced Editor.