Power QueryExercises

Expression.Error: We cannot apply operator to types Text and Number

By Tahir Nas · Examples run in our simulator · Published · Updated

Expression.Error: We cannot apply operator + to types Text and Number.

An arithmetic or comparison operator received values of incompatible types. M doesn't convert text to numbers automatically.

Common causes

How to fix it

  1. Set column types right after importing.
  2. Remove quotes from numeric literals.
  3. Use Text.From(number) when building text, and & for concatenation.

Find the step that fails

Minimal example

Raises the error:

"5" + 1

Fixed:

Number.From("5") + 1

Both snippets are run by the Power Query Exercises simulator on every build: the first must raise Expression.Error, the second must run.

Practise avoiding it

Guides

Related lessons