ID 25 - Concat function, Format

Max: 45
Try code in DAX.do

Syntax

FORMAT OR SELECTCOLUMNS

Related

SQL

SELECT employeename AS EmployeeName, CONCAT('₹', SALARY) AS Employee_Salary
FROM employee;

DAX

EVALUATE
SELECTCOLUMNS(
    employee,
    "EmployeeName", employee[employeename],
    "Employee_Salary", "₹" & FORMAT(employee[salary], "#,##0")
)

Pandas

import pandas as pd

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

df = pd.DataFrame(data)

# Prepend '₹' to the salary and rename the columns
df['Employee_Salary'] = '₹' + df['salary'].apply(lambda x: f"{x:,}")
df = df.rename(columns={'employeename': 'EmployeeName'})

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

Output

John Doe ₹70,000
Jane Smith ₹50,000
Alice Brown ₹60,000

Explanation

"₹" & FORMAT(employee[salary], "#,##0"): Prepends '₹' to the formatted salary. SELECTCOLUMNS: Creates a new table with columns EmployeeName and Employee_Salary.

Leave a Comment