Locked lesson.
About this lesson
This lesson shows how we can use errors to our benefit to solve conditional logic problems.
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.
Dealing with conditional logic errors.xlsx19.4 KB Dealing with conditional logic errors - Completed.xlsx
26.2 KB
Quick reference
Solving Logic Problems Using Errors
A demonstration of using errors to solve logic problems
When to use
When there are mixed data types in columns, you need to extract values from certain rows and don’t have a consistent pattern to exploit via conditional logic
Instructions
Getting Started
- Create a new query to bring your data to Power Query
Creating an Error Column
- Duplicate a column by right clicking its header --> Duplicate Column
- Change the data type on the column to trigger errors
- Right click the column --> Replace Errors --> enter null as the Value to use
Building Logic from Errors
- You can now build conditional logic to test if the value is equal to null
Finishing the Query
- Apply transformations as required
- Remove any unnecessary or “helper” columns
- Set data type for each remaining column
- Rename the query
- Close & Load the query
Hints & tips
- Converting to a text datatype will never trigger errors, but converting to any other data type will
- Duplicating the column may not be necessary, but it allows keeping a copy in place for further logic
Lesson notes are only available for subscribers.