Power Query if not a number then x else y

MartinL

Well-known Member
Joined
Oct 16, 2008
Messages
1,141
Office Version
  1. 365
Platform
  1. Windows
I'm trying to create a formula in Power Query which sums 3 elements
If the answer is not a number then enter M0 otherwise sum the 3 elements

Column12Column15Column16Column87
Widget1RedApplesM0
2349

I thought the code would be something like
Power Query:
if Number.IsNaN([Column12]+[Column15]+[Column16]) then "M0" else [Column12]+[Column15]+[Column16])

But that does not seem to work I just get Error for the first line
Column89 is set formatted as ABC123
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You could use:

Power Query:
try [Column12]+[Column15]+[Column16] otherwise "M0"

or you could just do the addition and then use a Replace Errors step on the column.
 
Upvote 0
Solution
You could use:

Power Query:
try [Column12]+[Column15]+[Column16] otherwise "M0"

or you could just do the addition and then use a Replace Errors step on the column.
OK try was a new one on me.
That worked a treat
 
Upvote 0

Forum statistics

Threads
1,225,611
Messages
6,185,996
Members
453,334
Latest member
Prakash Jha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top