Forum Discussion

jcastr02's avatar
jcastr02
Post Prodigy
5 years ago
Solved

Power query if formula

Can you help with a formula that would do the following in power query:

 

1. If the "Term Date" is blank then  (Today()-HireDate)  

 

If not blank

 

2.  TermDate-HireDate

 

Appreciate any help

  • = Table.AddColumn(PreviousStepName, "Days", each if [TermDate]=null then Duration.Days(Date.From(DateTime.LocalNow())-[HireDate]) else Duration.Days([TermDate]-[HireDate]), Int64.Type)

    It is assumed that [TermDate] & [HireDate] columns are of type date.

1 Reply

  • Jakinta's avatar
    Jakinta
    Solution Sage
    = Table.AddColumn(PreviousStepName, "Days", each if [TermDate]=null then Duration.Days(Date.From(DateTime.LocalNow())-[HireDate]) else Duration.Days([TermDate]-[HireDate]), Int64.Type)

    It is assumed that [TermDate] & [HireDate] columns are of type date.