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,
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,
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?
- ibarrau6 years agoSuper User
Can you please show us the error text? because I just test it and I'm sure it is not a date problem this time.
- Anonymous6 years agoNot applicable
ibarrauah, I managed to get it to work. I messed up the "applied steps" a bit and it broke cause of that.
So now I get both 0 and 1, but it still says that there are errors?
- Anonymous6 years agoNot applicable
Ok, it shows error when duedate is null. That's logic :) But is it a way to handle that? show 0 if duedate is null