Locked lesson.
About this lesson
Unfortunately, not every conditional logic scenario can be created using the "Conditional Column" tool. In this lesson you'll learn about the shortcomings of this tool and how to work around them by using the "Add Custom Column" button.
Exercise files
Download this lesson’s related exercise files. You can download source data files for the course from the resources section of your Lessons page.
Writing your own conditional formulae.xlsx19.3 KB Writing your own conditional formulae - Completed.xlsx
26.1 KB
Quick reference
Writing Your Own Conditional Formulae
An introduction to manually writing a conditional logic statement.
When to use
When you need to create a piece of conditional logic that cannot be created via the Add Conditional Column dialog.
Instructions
Getting started
- Create a new query to bring your data to Power Query
Creating custom column
- Go to the Add Column tab --> Custom Column
- In the Custom Column dialog
- Name the column
- Write the logic statement
Conditional logic syntax
- = if <logical test> then <result> else <alternate result>
- Notes
- The logic syntax in Power Query requires lowercase (e.g. if instead of IF)
- <logical test> must return a true or false value
- The final declaration is else (not “otherwise” as indicated in the Add Conditional Column dialog)
Finishing the query
- Apply transformations as required
- Set data type for each column
- Rename the query
- Close & Load the query
Hints & tips
- Like Excel, you can nest if statements within <logical test>, <result>, or <alternate result> sections
Lesson notes are only available for subscribers.