Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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! 🙂