Forum Discussion
If Statement in Power Query
Hey guys,
I have succesfully built this logic in DAX, but I need to create it in the power query. Could you help me with that?
If(Enrollment date>=Date(2019,01,01) && Enrollment date<=date(2019,12,31) && 'Program'='New', "2019', f(Enrollment date>=Date(2020,01,01) && Enrollment date<=date(2020,12,31) && 'Program'= "Old', "2020', else 'Other'
Thanks,
Sona
Anonymous here is PQ version
If [Enrollment date]>=#date(2019,01,01) and [Enrollment date]<=#date(2019,12,31) and [Program]="New" then "2019" else if [Enrollment date]>=#date(2020,01,01) and [Enrollment date]<=#date(2020,12,31) and [Program]= "Old" then "2020" else "Other"make sure column names are correct as per your table.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
1 Reply
- parry2kSuper User
Anonymous here is PQ version
If [Enrollment date]>=#date(2019,01,01) and [Enrollment date]<=#date(2019,12,31) and [Program]="New" then "2019" else if [Enrollment date]>=#date(2020,01,01) and [Enrollment date]<=#date(2020,12,31) and [Program]= "Old" then "2020" else "Other"make sure column names are correct as per your table.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡