Forum Discussion
Musketeers
10 years agoFrequent Visitor
if else condition with between operator
Hi, I am using M language and adding a new column in table. I need to write if condition in this line. I am writing if condition like this: if [Month] between 2 and 4 then "yes" else "no" Now...
- 10 years ago
Hi
You can do this
if [Month] >= 2 and [Month] <= 4 then "yes" else "no"
/Erik
donsvensen
10 years agoSkilled Sharer
Hi
You can do this
if [Month] >= 2 and [Month] <= 4 then "yes" else "no"
/Erik
- Musketeers10 years agoFrequent Visitor
Hi Erik,
Thanks for your reply.
Yes you are right. This is also a another way to do this.
But wanted to know if we can write this with Between Keyword as I was trying to write.
Any way I will use the way you have suggested.
Thanks
Rajneesh
- v-sihou-msft10 years agoMicrosoft Employee
In Power Query, there's no "between" keyword, you can only use operators to achieve this kind of logic as donsvensen suggested.
See: https://msdn.microsoft.com/en-us/library/mt186365.aspx
Regards,
- Musketeers10 years agoFrequent Visitor
Hi Simon, Thanks for your suggestion. Yes that way it is working. Thanks all for your time and suggestions.