Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Morning all,
I am having an issue with trying to add a column to track current employees on a report.
To explain what I am trying to achieve, I want to return "true" or "false" for employees based on their contract end date.
Any end dates that are blank/null or in the future would be true while in the past are false.
I have tried to get this with the below but am getting errors with the date if statement (I think due to null values).
Table.AddColumn(#"Added Custom", if[ContractEndDate] = null or [ContractEndDate] > DateTime.LocalNow then "True" else "False")
If I attempt to use the below on its own I get the error "Expression.Error: We cannot apply operator < to types Function and Null."
Table.AddColumn(#"Added Custom", if [ContractEndDate] > DateTime.LocalNow then "True" else "False")
Any ideas how I can fix this?
Many thanks,
Alex
Solved! Go to Solution.
Replace DateTime.LocalNow with
Date.From(DateTime.LocalNow())
Also just this much is enough (You hadn't supplied column name in your Table.AddColumn. I have named it Result)
= Table.AddColumn(#"Added Custom", "Result", each [ContractEndDate] = null or [ContractEndDate] > Date.From(DateTime.LocalNow()))
Replace DateTime.LocalNow with
Date.From(DateTime.LocalNow())
Also just this much is enough (You hadn't supplied column name in your Table.AddColumn. I have named it Result)
= Table.AddColumn(#"Added Custom", "Result", each [ContractEndDate] = null or [ContractEndDate] > Date.From(DateTime.LocalNow()))
Thank you for your help! 🙂