PowerBI filtering rows from table visual when values are missing

2 min read 05-10-2024
PowerBI filtering rows from table visual when values are missing


Power BI: Filtering Missing Values in Table Visuals

Problem: You're working with a Power BI table visual and want to filter out rows where certain columns have missing or blank values. But finding a simple solution to exclude these rows feels like a puzzle!

Solution: Filtering out rows with missing values in Power BI table visuals is actually straightforward with a bit of DAX and an understanding of how Power BI handles nulls.

Scenario:

Let's say you have a table named "Sales" with columns like "Product", "Region", "Sales Amount", and "Discount". You want to filter out rows where the "Discount" column has no value.

Original Code:

In the Power BI table visual, you might try using a filter on the "Discount" column. However, this will only show rows where a discount is explicitly defined. Rows with missing values will remain visible.

Insight:

Power BI uses the term "BLANK" to represent missing values. To effectively filter these out, you need to use a DAX expression that specifically checks for "BLANK".

Solution:

  1. Create a Calculated Column: Add a new calculated column to your "Sales" table called "Has Discount".

    Has Discount = IF(ISBLANK(Sales[Discount]), FALSE(), TRUE())
    

    This formula will return "TRUE" for rows where the "Discount" column has a value, and "FALSE" for rows with missing values.

  2. Filter the Table: In the Power BI table visual, add a filter on the "Has Discount" column and select "TRUE". This will only display rows where the "Discount" column has a value.

Additional Tips:

  • Filtering on Multiple Columns: You can apply the same logic to filter based on missing values in multiple columns. Just add multiple "ISBLANK" checks within the "IF" statement.
  • Using "NOT ISBLANK": If you want to keep only rows with missing values, you can use the "NOT ISBLANK" function in the DAX expression.
  • Customizing Visuals: Instead of adding a calculated column, you can create a custom measure to filter the table directly. This approach allows for greater flexibility and dynamic filtering.

Conclusion:

By utilizing DAX functions like "ISBLANK" and "NOT ISBLANK" you can effectively filter rows with missing values in Power BI table visuals. This helps you create clean and accurate reports that present only the relevant data. Remember to adapt the code to your specific column names and data structure.