Filtering While Retaining Missing Values

For example, suppose you use a filter to narrow down data targeting a column that contains missing values.

In this case, the filter normally works after excluding missing values.

Here, we’ll introduce a method to filter while keeping missing values.

By setting conditions in the filter dialog, a conditional expression will be displayed at the bottom of the dialog, so copy this.

Next, select “Custom” and enter the following formula:

is.na(Segment) | Segment %in% c("Consumer", "Corporate")

The is.na function determines whether a value is missing. Also, “|” represents an OR condition, so it will narrow down to values where either the value is missing or the Customer Segment is Consumer or Corporate.

By executing this, you can filter while retaining missing values.