Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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! 🙂
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.