ID 9 - Filter using where condition NOT IN

Max: 45
Try code in DAX.do

Syntax

COUNT FILTER NOT SELECTCOLUMNS

Related

SQL

SELECT customerName 
FROM customers 
WHERE country NOT IN ('GERMANY');

DAX

EVALUATE
SELECTCOLUMNS(
    FILTER(
        Customer,
        NOT Customer[CountryRegion] IN {"GERMANY"}
    ),
    "CustomerName", Customer[Name]
)

Pandas

import pandas as pd


df = pd.read_csv('customers.csv')

# Filter the DataFrame to exclude rows where country is 'GERMANY'
result = df[~df['country'].isin(['GERMANY'])][['customerName']]

# Convert to a list of lists
result_list = result.values.tolist()

print(result_list)

Output

John Doe
Jane Smith
Bob Brown
Alice White

Explanation

FILTER(Customers, NOT Customers[country] IN {"GERMANY"}): Filters the Customers table to exclude rows where the country is 'GERMANY'. SELECTCOLUMNS: Selects the customerName column and returns it as "CustomerName" in the output.

Leave a Comment