ID 7 - Filter using where condition or

Max: 45
Try code in DAX.do

Syntax

FILTER SELECTCOLUMNS YEAR

Related

SQL

SELECT customerName 
FROM customers 
WHERE city = 'Las Angeles' 
  OR Yearly_Income <= 21000;

DAX

EVALUATE
SELECTCOLUMNS(
    FILTER(
        Customer,
        Customer[city] = "Las Angeles" || Customers[Yearly Income] <= 21000
    ),
    "CustomerName", Customer[Name]
)
 

Pandas

import pandas as pd

df = pd.read_csv('customers.csv')  # Example of loading data

# Filter the DataFrame to include rows where city is 'Las Angeles' or Yearly Income is less than or equal to 21,000
result = df[(df['city'] == 'Las Angeles') | (df['Yearly Income'] <= 21000)][['customerName']]

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

print(result_list)

Output

John Doe
Jane Smith
Mary Jones
Bob Brown

Explanation

FILTER(Customers, Customers[city] = "Las Angeles" || Customers[Yearly Income] <= 21000): Filters the Customers table to include rows where either the city is 'Las Vegas' or Yearly Income is less than or equal to 21,000. SELECTCOLUMNS: Selects the customerName column and returns it as "CustomerName" in the output.

Leave a Comment