Power Query Error: Cannot Apply Operator & to Types Text and Number

PL-300 By islever Editorial Last updated

Short answer

The error is caused by mismatched data types. The desired outcome of the custom column is A1.

Question

HOTSPOT
You attempt to use Power Query Editor to create a custom column and receive the error message shown in the following exhibit.
Exhibit: Power Query Error: Cannot Apply Operator & to Types Text and Number
Use the drop-down menus to select the answer choice that completes each statement based on the information presented in the graphic.
NOTE: Each correct selection is worth one point.
Exhibit: Power Query Error: Cannot Apply Operator & to Types Text and Number

Key Takeaways

The core concept tested is Power Query's strict typing system, where the ampersand (&) operator fails if one operand is text and the other is a number, requiring explicit conversion via Text.From().

This question addresses the Power Query error regarding mismatched data types during concatenation. The correct resolution involves converting the number to text to achieve the desired output of A1.

Common mistake: Candidates often misinterpret the error as a syntax issue or believe the column name itself is invalid. They may overlook that the root cause is the incompatibility between Text and Number types rather than the structure of the formula.

Expert Analysis

The error message displayed in the exhibit is Expression.Error: We cannot apply operator '&' to types Text and Number. This specific error occurs in Power Query when attempting to concatenate (join) two values using the ampersand symbol, but those values have incompatible data types. In this scenario, one operand is a text string (e.g., "A") and the other is a numeric value (e.g., 1). Power Query requires both operands to be of the same type for concatenation; therefore, the mismatch causes the failure.

To resolve this, you must convert the number to text before applying the ampersand operator. Once converted, the resulting custom column will combine the text prefix with the numeric suffix. For example, converting the number 1 to text allows the expression "A" & Text.From([Column]) to produce the string "A1". Thus, the desired outcome of the custom column is the concatenated string A1.

Exam Strategy

When encountering Power Query errors related to operators, always check the data types of the involved columns. If an operation like concatenation fails, use the Type column in the editor to identify mismatches and apply transformation functions like Text.From() or Number.ToText() to align the types.

Frequently Asked Questions

What function converts a number to text in Power Query?

Use the Text.From() function to convert a number to text. This allows you to concatenate it with other text strings using the ampersand (&) operator without triggering a type mismatch error.

Why does the ampersand operator fail in Power Query?

The ampersand operator requires both operands to be of the Text data type. If you try to concatenate a text value with a number, Power Query throws an error because it cannot implicitly convert the number to text during the operation.

Discussion 14 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 14

  1. RazaTheLegend 👍 49
    Given answers are correct
  2. Igetmyrole 👍 23
    Mismatched data types and A1 are the correct answers. The custom column expression is trying to concatenate (use the "&" operator) a text value and a number value, which are mismatched data types. In this case, the left side of the operator is a text value (e.g.,"A"), and the right side is a number value (e.g.,1). To achieve the desired outcome of the custom column as "A1", you should ensure that both sides of the "&" operator have the same data type, which is text in this case.
  3. joaowendling 👍 21
    In the error message, you can see that we are trying to concatenate two "parts", the left one (which is "A") and the right one (which is the number 1). The "&" is how we are concatenating (in Power Query the syntax "abc"&"def" will result in "abcdef"
  4. lizbette 👍 6
    can someone explain the syntax? where did the "&" come from? what does the { } mean"
  5. Shalaleh 👍 5
    Given answer is correct.
Show 9 more comments
  1. omath 👍 2
    Answers: - The error is caused by: mismatched data types - The desired outcome of the custom column is: A1 Explanation: - Error message: Expression.Error: We cannot apply operator & to types Text and Number. This means the issue is due to mismatched data types (text vs number) when using the & operator. - Desired outcome: The formula is trying to concatenate "A" and 1. The expected result is A1 (not A&1 and not 1A).
  2. rcaliandro 👍 2
    The error is caused by mismatched data types (text and number). The desired outcome of the custom column is A1. The given answer is OK
  3. saarah9 👍 2
    The error is caused by: mismatched data types The desired outcome of the custom column is: A1
  4. PBI2916 👍 2
    I tried "A"&1 to create custom column . It gives the same error as shown in the picture.
  5. KARELA 👍 2
    can someone please share the resource from where this is referenced?
  6. dataguru08 👍 2
    Can someone please explain why is it A1?
  7. Mogo111 👍 1
    mismatch data types, a1
  8. BP215 👍 1
    Correct answer
  9. LuluSkyy 👍 1
    correct

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All PL-300 Questions

Access 116 questions with complete answers and detailed explanations.

View Full PL-300 Practice Test →

← Back to PL-300 Study Guide