Bird
Raised Fist0
Tableaubi_tool~20 mins

Type conversion functions in Tableau - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Type Conversion Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
dax_lod_result
intermediate
1:30remaining
Output of INT() conversion in Tableau
What is the output of the following Tableau calculated field?

INT("123.99")

Assume the input is a string and INT() converts it to an integer.
Tableau
INT("123.99")
A123
B124
C123.99
DError: Cannot convert string with decimal to INT
Attempts:
2 left
💡 Hint
INT() truncates decimal parts after converting to number.
visualization
intermediate
1:30remaining
Visualizing type conversion impact on data
You have a dataset with a field 'Sales' stored as string values like '1000', '2000', '3000'. You want to create a bar chart showing total sales.

Which Tableau calculated field should you use to correctly sum sales as numbers?
ASUM(STR([Sales]))
BSUM([Sales])
CSUM(INT([Sales]))
DSUM(FLOAT([Sales]))
Attempts:
2 left
💡 Hint
Sales values have decimals possible, so use a conversion that supports decimals.
🧠 Conceptual
advanced
2:00remaining
Understanding type conversion errors in Tableau
Which of the following scenarios will cause a type conversion error in Tableau when using INT() or FLOAT() functions?
AConverting a number 123 to INT()
BConverting a string 'abc123' to INT()
CConverting a string '123.45' to FLOAT()
DConverting a string '1000' to FLOAT()
Attempts:
2 left
💡 Hint
Think about what strings can be converted to numbers.
data_modeling
advanced
2:00remaining
Choosing correct type conversion for date calculations
You have a string field 'OrderDate' in format '2023-06-15'. You want to calculate the number of days since this date.

Which Tableau calculated field correctly converts 'OrderDate' to a date type for this calculation?
ADATEDIFF("day", STR([OrderDate]), TODAY())
BDATEDIFF("day", INT([OrderDate]), TODAY())
CDATEDIFF("day", DATE([OrderDate]), TODAY())
DDATEDIFF("day", FLOAT([OrderDate]), TODAY())
Attempts:
2 left
💡 Hint
Dates must be converted to date type, not numbers or strings.
🔧 Formula Fix
expert
2:30remaining
Debugging type conversion in nested calculations
Given the Tableau calculated field:

IF INT([Score]) > 50 THEN "Pass" ELSE "Fail" END

Which issue will cause this calculation to fail or produce incorrect results?
Tableau
IF INT([Score]) > 50 THEN "Pass" ELSE "Fail" END
AIf [Score] contains null or non-numeric strings, INT() will cause an error
BComparison operator '>' is invalid in Tableau calculated fields
CThe ELSE clause is missing a return value causing syntax error
DINT() converts decimals correctly, so no issues expected
Attempts:
2 left
💡 Hint
Consider what happens if input is not a clean number string.

Practice

(1/5)
1. Which Tableau function converts a string like '123' into an integer?
easy
A. FLOAT()
B. STR()
C. DATE()
D. INT()

Solution

  1. Step 1: Understand the input type

    The input is a string '123' which represents a number but is stored as text.
  2. Step 2: Choose the function to convert string to integer

    INT() converts a string that looks like a number into an integer type.
  3. Final Answer:

    INT() -> Option D
  4. Quick Check:

    String '123' to number = INT() [OK]
Hint: Use INT() to convert numeric strings to whole numbers [OK]
Common Mistakes:
  • Using STR() which converts numbers to strings
  • Using DATE() which converts to date format
  • Using FLOAT() when integer is needed
2. Which of the following is the correct syntax to convert a date string '2023-06-01' to a date in Tableau?
easy
A. FLOAT('2023-06-01')
B. DATE('2023-06-01')
C. INT('2023-06-01')
D. STR('2023-06-01')

Solution

  1. Step 1: Identify the data type to convert to

    The string '2023-06-01' represents a date, so we want to convert it to a date type.
  2. Step 2: Use the DATE() function for conversion

    DATE() converts a string formatted as a date into a Tableau date type.
  3. Final Answer:

    DATE('2023-06-01') -> Option B
  4. Quick Check:

    Convert date string to date = DATE() [OK]
Hint: Use DATE() to convert date strings to date type [OK]
Common Mistakes:
  • Using STR() which converts to string, not date
  • Using INT() or FLOAT() which cause errors on date strings
  • Missing parentheses in function call
3. What is the result of this Tableau calculation?
INT('45.67')
medium
A. Error
B. 45
C. 46
D. 45.67

Solution

  1. Step 1: Analyze the input string

    The string '45.67' represents a decimal number.
  2. Step 2: Understand INT() behavior on decimal strings

    INT() expects a string representing an integer; passing a decimal string causes an error in Tableau.
  3. Final Answer:

    Error -> Option A
  4. Quick Check:

    INT('45.67') causes error [OK]
Hint: INT() only converts strings representing whole numbers [OK]
Common Mistakes:
  • Expecting an error on decimal strings
  • Thinking INT() rounds up to 46
  • Confusing truncation with keeping decimals
4. You wrote this Tableau formula but get an error:
FLOAT('abc')

What is the likely cause?
medium
A. The string 'abc' cannot convert to a number
B. FLOAT() requires a date input
C. Missing quotation marks around abc
D. FLOAT() only works on integers

Solution

  1. Step 1: Check the input string

    The string 'abc' contains letters, not numeric characters.
  2. Step 2: Understand FLOAT() conversion rules

    FLOAT() converts strings representing numbers to decimal numbers; non-numeric strings cause errors.
  3. Final Answer:

    The string 'abc' cannot convert to a number -> Option A
  4. Quick Check:

    Non-numeric string to FLOAT() = Error [OK]
Hint: Only numeric strings convert with FLOAT() [OK]
Common Mistakes:
  • Thinking FLOAT() works on any string
  • Assuming FLOAT() needs date input
  • Forgetting quotes around strings
5. You have a field [Sales] stored as string values like '1000', '2000', and '3000'. You want to calculate the average sales as a number. Which formula correctly converts and averages these values?
hard
A. INT(AVG([Sales]))
B. AVG(STR([Sales]))
C. AVG(INT([Sales]))
D. AVG(DATE([Sales]))

Solution

  1. Step 1: Convert string sales to numbers before averaging

    Since [Sales] is string, convert each value to integer using INT() first.
  2. Step 2: Apply AVG() on converted integers

    AVG(INT([Sales])) calculates the average of numeric sales correctly.
  3. Final Answer:

    AVG(INT([Sales])) -> Option C
  4. Quick Check:

    Convert then average = AVG(INT()) [OK]
Hint: Convert strings to numbers before aggregation [OK]
Common Mistakes:
  • Averaging strings directly causes errors
  • Converting after averaging strings is invalid
  • Using DATE() on numeric strings