Forum Discussion
Bug? - IsInNextNMonths
- 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...
- 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
1st photo - 26 June 23, is showing within 12 months. It's only the 15th, it should be showing 18.
2, 3, 4 , the updated formula I'm trying and the error it created.
I cannot read those photos clearly, and stuff is cut off.
I mocked up some quick data and it works just fine. The June and July dates in the future show expiring. You need to really test for current month and in the future, and next 1 month.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtM3NNU3MjAyUorViVYy1Tc0Q/DMUeQsUHhmCJWxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
#"Sorted Rows" = Table.Sort(Source,{{"Date", Order.Ascending}}),
#"Changed Type" = Table.TransformColumnTypes(#"Sorted Rows",{{"Date", type date}}),
#"Added Expiring" =
Table.AddColumn(
#"Changed Type",
"Expiring in Next 2 Months",
each Date.IsInNextNMonths([Date], 1) or (Date.IsInCurrentMonth([Date]) and [Date] >= DateTime.Date(DateTime.LocalNow())),
Logical.Type
)
in
#"Added Expiring"
Again, if you want some detailed help, I'll repeat my request. If you can post data per below with expected output we can assist with a formula that works.
How to get good help fast. Help us help you.
How To Ask A Technical Question If you Really Want An Answer
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.