Medium severitysql
Power BI Refresh Error:
CAST_INVALID_INPUT
What does this error mean?
A CAST or implicit type conversion failed because the input value cannot be converted to the target data type. The query is aborted — no partial conversion is performed.
Common causes
- 1Casting a STRING column that contains non-numeric values (e.g., 'N/A', '') to INT or DOUBLE
- 2Casting a malformed date string to DATE or TIMESTAMP (e.g., '2024-13-01' or '01/15/2024')
- 3An upstream pipeline change introduced new string formats or sentinel values into a numeric column
- 4Implicit casting in a JOIN condition between incompatible types
- 5A CSV or JSON source file containing unexpected null representations that fail type conversion
How to fix it
- 1Use TRY_CAST(col AS INT) to return NULL instead of failing on invalid input
- 2Filter out or transform invalid values before the CAST: WHERE col RLIKE '^[0-9]+$'
- 3Inspect sample values: SELECT DISTINCT col FROM table WHERE TRY_CAST(col AS INT) IS NULL AND col IS NOT NULL
- 4Fix the source data or upstream pipeline to produce clean, correctly typed values
- 5Add a data contract or schema enforcement step at the ingestion layer to catch type issues early