ID 2 - Filter using where condition

Max: 45
Try code in DAX.do

Syntax

FILTER SELECTCOLUMNS

Related

24 - converts employee names to uppercase and calculates the length of the employee names 6 - Filter using where condition and 9 - Filter using where condition NOT IN 13 - Filter using where condition like 10 - Filter using where condition between

SQL

SELECT customerName 
FROM customers 
WHERE city = 'Los Angeles';

DAX

EVALUATE
SELECTCOLUMNS(
    FILTER(
        Customer,
        Customer[city] = "Los Angeles"
    ),
    "CustomerName", Customer[Name]
)

Pandas

import pandas as pd

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

# Filter the DataFrame to only include rows where city is 'Los Angeles'
result = df[df['city'] == 'Los Angeles'][['customerName']]

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

print(result_list)

Output

John Doe
Mary Jones

Explanation

FILTER(Customers, Customers[city] = "Los Angeles"): Filters the Customers table to only include rows where city is 'Los Angeles'. SELECTCOLUMNS: Selects the customerName column and returns it as "CustomerName" in the output.

YouTube Video Link

YouTube Video

Leave a Comment