ID 24 - converts employee names to uppercase and calculates the length of the employee names

Max: 45
Try code in DAX.do

Syntax

LEN SELECTCOLUMNS UPPER

Related

35 - Find Customers with No Phone Number 34 - Split and Group By

SQL

SELECT UCASE(employeename) AS EmployeeName_UpperCase, CHAR_LENGTH(employeename) AS Name_Length
FROM employee;

DAX

EVALUATE
SELECTCOLUMNS(
    employee,
    "EmployeeName_UpperCase", UPPER(employee[employeename]),
    "Name_Length", LEN(employee[employeename])
)

Pandas

import pandas as pd

# Sample DataFrame
data = {
    'employeename': ['John Doe', 'Jane Smith', 'Alice Brown']
}

df = pd.DataFrame(data)

# Convert the employeename to uppercase and calculate the length
df['EmployeeName_UpperCase'] = df['employeename'].str.upper()
df['Name_Length'] = df['employeename'].str.len()

# Select the necessary columns
result = df[['EmployeeName_UpperCase', 'Name_Length']].values.tolist()
print(result)

Output

JOHN DOE 8
JANE SMITH 10
ALICE BROWN 11

Explanation

UPPER(employee[employeename]): Converts the employeename to uppercase. LEN(employee[employeename]): Calculates the length of the employeename. SELECTCOLUMNS: Creates a new table with columns EmployeeName_UpperCase and Name_Length based on the employee table.

Leave a Comment