Forum Discussion
gemcityzach
2 years agoHelper IV
Calculating due dates in the future intervals
I have a table with a number of fields including created date, issued date, effective date, closed date, etc. I want to create calculated columns to determine if the effective date is in 30 days, 60 ...
- 2 years ago
Try checking for null first:
each if [Effective_Date] is null then null else if [Effective_Date] < DateTime.Date(DateTime.LocalNow()) then "NONE" else if Date.IsInNextNDays([Effective_Date], 30) then "dueNext30" else if Date.IsInNextNDays([Effective_Date], 60) then "dueNext60" else if Date.IsInNextNDays([Effective_Date], 90) then "dueNext90" else if Date.IsInNextNDays([Effective_Date], 120) then "dueNext120" else "due>120"
gemcityzach
2 years agoHelper IV
I'm getting all kinds of errors, particularly for dates that are now in the past or even in the near future (90 days out). Any thoughts on resolving that?
= Table.AddColumn(#"Changed Type", "dueNext30", each if Date.IsInNextNDays([Effective_Date], 30) & [Effective_Date] <> "null" then
"dueNext30"
else if Date.IsInNextNDays([Effective_Date], 60) & [Effective_Date] <> "null" then
"dueNext60"
else if Date.IsInNextNDays([Effective_Date], 90) & [Effective_Date] <> "null" then
"dueNext90"
else if Date.IsInNextNDays([Effective_Date], 120) & [Effective_Date] <> "null" then
"dueNext120"
else
"NONE")
DataInsights
2 years agoSuper User
Try checking for null first:
each
if [Effective_Date] is null then
null
else if [Effective_Date] < DateTime.Date(DateTime.LocalNow()) then
"NONE"
else if Date.IsInNextNDays([Effective_Date], 30) then
"dueNext30"
else if Date.IsInNextNDays([Effective_Date], 60) then
"dueNext60"
else if Date.IsInNextNDays([Effective_Date], 90) then
"dueNext90"
else if Date.IsInNextNDays([Effective_Date], 120) then
"dueNext120"
else
"due>120"