You have used if...then...else for defining custom columns. But did you know you can also use if...then...else statement for code branching. M being a functional language is unlike other programming languages (say Visual Basic/VBA or C#). So things work a little differently here. This post will show you how you can execute two separate code paths in M based on a given condition.
Read more...
Power_BI_Query_If_then_else.pbix