ID 8 - Filter using where condition in

Max: 45
Try code in DAX.do

Syntax

AND COUNT FILTER SELECTCOLUMNS

Related

SQL

SELECT customerName 
FROM customers 
WHERE country IN ('France', 'India', 'Poland');

DAX

EVALUATE
SELECTCOLUMNS(
    FILTER(
        Customer,
        Customer[CountryRegion] IN {"France", "India", "Poland"}
    ),
    "CustomerName", Customer[Name]
)

Pandas

import pandas as pd

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

# Filter the DataFrame to include rows where country is in the specified list
result = df[df['country'].isin(['France', 'India', 'Poland'])][['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, Customers[country] IN {"France", "India", "Poland"}): Filters the Customers table to include rows where the country is either 'France', 'India' or 'Poland'. SELECTCOLUMNS: Selects the customerName column and returns it as "CustomerName" in the output.

Leave a Comment