Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Candi
New Member

Expression Error We cannot apply operator - to types Text and Text

Hi,

I keep receiving this error when trying to run my power query, and I can't figure out how to solve it.  Any help would be appreciated.Screenshot 2024-08-13 124914.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for reaching out to the community, @Candi .

 

It's an easy question. I reproduced it.

vstephenmsft_0-1723624295549.png

The step I did was subtract 1 from the [Hours] column, and the reason for the error was that my [Hours] was of type text.(Text cannot be added or subtracted.) 

vstephenmsft_1-1723624335649.png

Just turn the [Hours] column into a numeric type before performing the subtraction step.

vstephenmsft_2-1723624571707.png

Of course, if you're not here for addition and subtraction, you're trying to add a "-" between the fields and the fields. Then you can do it as follows.

vstephenmsft_3-1723624821857.png

Another note, the merge must be text, e.g. [Hours] is a numeric type and not a text type, you need to modify the code as follows

vstephenmsft_4-1723624988949.png

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Thanks for reaching out to the community, @Candi .

 

It's an easy question. I reproduced it.

vstephenmsft_0-1723624295549.png

The step I did was subtract 1 from the [Hours] column, and the reason for the error was that my [Hours] was of type text.(Text cannot be added or subtracted.) 

vstephenmsft_1-1723624335649.png

Just turn the [Hours] column into a numeric type before performing the subtraction step.

vstephenmsft_2-1723624571707.png

Of course, if you're not here for addition and subtraction, you're trying to add a "-" between the fields and the fields. Then you can do it as follows.

vstephenmsft_3-1723624821857.png

Another note, the merge must be text, e.g. [Hours] is a numeric type and not a text type, you need to modify the code as follows

vstephenmsft_4-1723624988949.png

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks!  This was helpful and I was able to solve the error.  However, another has popped up.  I believe it's telling me that when it tries to run that particular  (Operating Debit Master - Subtract' query, the table is empty?  I just can't seem to identify which table.

Screenshot 2024-08-14 135652.png

PwerQueryKees
Super User
Super User

The error message says you are trying to subtract a text field from another text field....

PwerQueryKees
Super User
Super User

We need more info than this. Can you show the data and the formula throwing the error?

Full disclosure, my former coworker built this power query.  He showed me how to solve a lot of the errors that we encountered in the past, but this one is new. 

 

I'm not sure which data/formula is causing the error.  I've gone into the power query editor to try to figure it out and I believe I've identified which table is the problem, but I've gone through the entire source workbook, but still couldn't find the issue.

Go through the applied steps and see on which step that error first appears. The error means pretty much what it says. You have text data that you are trying to subtract.

Possibly a silly question, but there are names included in the fields where the last names are hypenated.  Is there a possiblity that it's interpreting this as subtracting text?

Unlikely, but without data and code, it is not possible to tell you precisely how to change things to avoid this error.

Ok.  Thanks

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.