Forum Discussion

chelynne's avatar
chelynne
Regular Visitor
4 years ago
Solved

Bug? - IsInNextNMonths

I'm experiencing some very weird results with this powerquery formula. I know the formula is a bit janky, but it's not working as it should.    1st pic - formula, 2nd pic - weird result. June 26th ...
  • edhans's avatar
    4 years ago

    Both Date.IsInNextNMonths and Date.IsInPreviousMonths ignore the current month, because the current month is not in the next months, you cannot use either as an absolute for future/past. You'd need to use an OR condition with Date.IsInCurrentMonth. and is after today.


    for example:

    Date.IsInNextNMonths([Date], 6) or (Date.IsInCurrentMonth([Date]) and [Date] > DateTime.Date(DateTime.LocalNow()))

    With today being June 14, 2022...

     

  • chelynne's avatar
    chelynne
    4 years ago

    I thought this made sense, but it's throwing an error for the affected lines. I'll update with errors soon.

    It also did not fix the problem of June 26th showing within the next 12 months. 

    I still think there's a bug regarding what it considers a month