Monday, August 29, 2022

Power Query - Date is within the last 18 Months Custom Column


 Here are directions on how to create a custom column in Power BI, Power Query that tells you if a date is within the last 18 months.

if DateTime.Date(DateTime.LocalNow())<Date.AddMonths([Release Date],18) then "Compliant" else "Noncompliant"

The number can be changed so that it fits your needs.

On a different note, if you wanted to compare a date to see if it is within the current year, this would be the code you would use to create a custom column:

if Number.From(Date.Year(DateTime.LocalNow()))=[Release Year] then "Compliant" else "Noncompliant"

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.