Forum Discussion

KrisF's avatar
KrisF
Frequent Visitor
3 years ago
Solved

list.dates generates DataFormat.Error: We couldn't convert to Date

Hello,  Within a Dataflow, I am attempting to generate a list of dates between a Start and and End Date however when i create the custom column the "DataFormat.Error: We couldn't convert to Date" er...
  • BA_Pete's avatar
    3 years ago

    Hi KrisF ,

     

    I'd do it this way:

     

    Create a new column for a bounded end date that's not 7,000 years in the future:

    endDateFilled =
    if Date.Year([End_Date]) > 3000 or [End_Date] = null then Date.From(DateTime.LocalNow())
    else [End_Date]

     

    Create another new column for your date list:

    List.Transform(
        { Number.From([Start_Date])..Number.From([endDateFilled]) },
        each List.Distinct(Date.EndOfMonth(Date.From(_)))
    )

     

    You should now be able to expand this new column for your list of month-end dates.

     

    Pete