Forum Discussion
Pascal_Werner
Jun 04, 2024Copper Contributor
"if" function in Power Query not working properly
Good day, I have a power query set up that is giving me the number of days between task completions during a large project. However, I am missing the time from the last completed task until "today"...
NikolinoDE
Jun 05, 2024Gold Contributor
= Table.AddColumn(
PreviousStepName,
"DaysBetweenTasks",
each if [#"Final Walkdown"] = [#"Completed"]
then 0
else if [#"Final Walkdown"] <> null and [#"Final Walkdown"] <> ""
then Duration.Days(DateTime.Date([#"Completed"]) - DateTime.Date([#"24-Hour Run Test"]))
else if [#"24-Hour Run Test"] <> null and [#"24-Hour Run Test"] <> ""
then Duration.Days(DateTime.Date([#"Completed"]) - DateTime.Date([#"Rotor Install"]))
else if [#"Rotor Install"] <> null and [#"Rotor Install"] <> ""
then Duration.Days(DateTime.Date([#"Completed"]) - DateTime.Date([#"Rotor Removal"]))
else if [#"Rotor Removal"] <> null and [#"Rotor Removal"] <> ""
then Duration.Days(DateTime.Date([#"Completed"]) - DateTime.Date([#"Prework Walkdown"]))
else 0
)
NOTE: My knowledge with Power BI is limited, maybe this revised version will help you with your project, if not, just ignore it .
Nevertheless, I hope that I could help with this.