Forum Discussion
Power Query - custom column - date -2 and another condition
- 6 years ago
You have to ask first for null in order to avoid the comparison between null and dates.
if [DueDate] = null then 0 else if [DueDate] <= Date.AddDays (DateTime.Date(DateTime.LocalNow()), -2) and [ShortListCount] = 0 then 1 else 0
Be carefull with quotes. If you type "1" the result will be a text 1 and not a number.
Regards,
Hi. In the definition you mention a duedate is less than two days from now and the formula is duedate is exactly two days ago.
Are you sure you are not looking for this:
= Table.AddColumn(#"Changed Type1", "red", each if [DueDate] <= Date.AddDays (Date.From(DateTime.FixedLocalNow()), -2) and [ShortListCount] = 0 then "1" else 0)
Be sure to show us a row that is not fulfilling this conditions in case you have 0 again.
Regards,
- Anonymous6 years agoNot applicable
Hi ibarrau and thanks for answering.
I tried that as well but then I get an error in all columns:
This should trigger 1
- ibarrau6 years agoSuper User
Ok, let's use a Date for now instead Datetime.
= Table.AddColumn(#"Changed Type1", "red", each if [DueDate] <= Date.AddDays (DateTime.Date(DateTime.LocalNow()), -2) and [ShortListCount] = 0 then "1" else 0)
This should work.
Regards,
- Anonymous6 years agoNot applicable
Still the same error, but I get 0 when the duedate is null
seems to me that id does not like the < sign when using dates?