Forum Discussion
Power query - if function with dates
- Anonymous5 years ago
Hi Anonymous ,
You can add custom column with the formula as shown in below screenshot, later please adjust the conditions base on your scenario..
=if [Release date] < #date(2020, 1, 1) then 1 else if [Release date] > #date(2019, 12, 31) and [Release date] < #date(2021, 1, 1) then 2 else if [closed date] < #date(2021, 1, 1) then 3 else 0Best Regards
You can use this formula in a custom column in the query editor
= if [release date] < #date(2020,1,1) then "1" else if ([release date] > #date(2019,12,31) and [release date] < #date(2020,1,1)) then "2" else if [closed date] < #date(2021,1,1) then "3" else "other"
Note your #2 condition seems off, so you can adjust as needed.
Regards,
Pat
- Anonymous5 years agoNot applicable
I wrote this and I have "Error" in each cell instead of "1", "2" etc. :c
- Anonymous3 years agoNot applicable
I encountered the same issue. Check if the Data Type of your date columns ([release date], [closed date]) is in "Date". The above doesn't seem to work on "Date/Time" data. I tried it on "Date" data and it worked.