Table of Contents
The “NOT IN” operator in Power BI is used to filter data based on a list of values that are not included in a specified column or measure. This can be useful for eliminating specific data points from a visualization or calculation. For example, if we have a dataset of customer orders and we want to see the total sales for all customers except for those in a specific region, we can use the “NOT IN” operator to exclude the region from our results. This would give us a clear picture of sales for all regions except the one we specified.
You can use the following syntax in DAX to use a “NOT IN” operator:
filtered_data = CALCULATETABLE('my_data', NOT('my_data'[Team] IN {"A", "C"}))
This particular example creates a new table named filtered_data that only contains the rows from the table named my_data where the value in the Team column is not equal to A or C.
Note that we used curly brackets { } when specifying the values in our list.
The following example shows how to use this syntax in practice.
Example: How to Use “NOT IN” Operator in Power BI
Suppose we have the following table in Power BI named my_data that contains information about basketball players on various teams:
Suppose we would like to create a new table that only contains players who are not on teams A or C.
To do so, click the Table tools tab and then click the New table icon:
Then type in the following formula into the formula bar:
filtered_data = CALCULATETABLE('my_data', NOT('my_data'[Team] IN {"A", "C"}))
This will create a new table named filtered_data that only contains players who are not on teams A or C:
Note that you can also use multiple NOT IN filters if you’d like.
For example, you could create a new table where the following conditions are both true:
- The value in the Team column is not A or C
- The value in the Position column is not Guard or Center
You can use the following syntax to do so:
filtered_data = CALCULATETABLE('my_data', NOT('my_data'[Team] IN {"A", "C"}) && NOT('my_data'[Position] IN {"Guard", "Center"}))
This will create a new table named filtered_data that only contains players who are not on teams A or C and who also do not have a position of Guard or Center:
Note: You can find a complete list of operators you can use in DAX .
Additional Resources
The following tutorials explain how to perform other common tasks in Power BI: