ID 12 - Filter using where condition like

Max: 45
Try code in DAX.do

Syntax

COUNT FILTER RIGHT SELECTCOLUMNS

Related

SQL

SELECT customerName, country 
FROM customers 
WHERE country LIKE '%S';

DAX

EVALUATE
SELECTCOLUMNS(
    FILTER(
        Customer,
        RIGHT(Customer[CountryRegion], 1) = "S"
    ),
    "CustomerName", Customer[Name],
    "Country", Customer[CountryRegion]
)

Pandas

import pandas as pd

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

# Filter the DataFrame to include rows where the country ends with 'S'
result = df[df['country'].str.endswith('S')][['customerName', 'country']]

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

print(result_list)

Output

John Doe United States
Mary Jones Netherlands

Explanation

FILTER(Customers, RIGHT(Customers[CountryRegion], 1) = "S"): Filters the Customers table to include rows where the country ends with the letter 'S'. SELECTCOLUMNS: Selects the customerName and country columns and returns them as "CustomerName" and "Country" in the output

Leave a Comment