0
0
Tableaubi_tool~15 mins

Type conversion functions in Tableau - Real Business Scenario

Choose your learning style9 modes available
Scenario Mode
👤 Your Role: You are a sales analyst at a retail company.
📋 Request: Your manager wants you to prepare a report that shows total sales by month and also the average sales per customer. However, the sales data has some numbers stored as text, and the dates are stored as strings. You need to convert these to the correct types to perform calculations.
📊 Data: You have a sales dataset with columns: 'Order ID' (text), 'Order Date' (string in format 'YYYY-MM-DD'), 'Customer ID' (text), 'Sales Amount' (text representing numbers), and 'Quantity' (number).
🎯 Deliverable: Create a Tableau worksheet that shows total sales by month and average sales per customer, using type conversion functions to fix data types.
Progress0 / 6 steps
Sample Data
Order IDOrder DateCustomer IDSales AmountQuantity
ORD0012024-01-15CUST01100.502
ORD0022024-01-20CUST022001
ORD0032024-02-05CUST01150.753
ORD0042024-02-18CUST033001
ORD0052024-03-10CUST02250.252
ORD0062024-03-15CUST044004
ORD0072024-03-20CUST013501
ORD0082024-04-01CUST03500.505
1
Step 1: Create a calculated field named 'Sales Amount Number' to convert 'Sales Amount' from text to number.
FLOAT([Sales Amount])
Expected Result
Converts sales amounts like '100.50' and '200' to numeric values 100.5 and 200.
2
Step 2: Create a calculated field named 'Order Date Date' to convert 'Order Date' from string to date type.
DATE([Order Date])
Expected Result
Converts strings like '2024-01-15' to date values January 15, 2024.
3
Step 3: Create a calculated field named 'Month' to extract the month and year from 'Order Date Date' for grouping.
DATETRUNC('month', [Order Date Date])
Expected Result
Groups dates like '2024-01-15' and '2024-01-20' into January 2024.
4
Step 4: Create a worksheet with Rows set to 'Month' and Columns showing 'SUM of Sales Amount Number'.
Drag 'Month' to Rows, drag 'Sales Amount Number' to Columns, set aggregation to SUM.
Expected Result
Shows total sales for each month: Jan, Feb, Mar, Apr.
5
Step 5: Create a calculated field named 'Average Sales per Customer' to calculate average sales per unique customer.
SUM([Sales Amount Number]) / COUNTD([Customer ID])
Expected Result
Calculates average sales amount per customer across all orders.
6
Step 6: Add 'Average Sales per Customer' as a label or tooltip on the monthly sales chart for additional insight.
Drag 'Average Sales per Customer' to Tooltip or Label shelf.
Expected Result
Shows average sales per customer for each month when hovering or as label.
Final Result
Month       | Total Sales | Avg Sales per Customer
-----------------------------------------------
2024-01-01  | $300.50     | $150.25
2024-02-01  | $450.75     | $225.38
2024-03-01  | $1000.25    | $333.42
2024-04-01  | $500.50     | $500.50
Sales increased steadily from January to March.
March had the highest total sales.
April had the highest average sales per customer but only one order.
Bonus Challenge

Create a calculated field that converts 'Quantity' to text and then back to number, and verify it matches the original 'Quantity'.

Show Hint
Use STR() to convert number to string and INT() or FLOAT() to convert back to number.