How to split postal area from post code

masplin

Active Member
Joined
May 10, 2010
Messages
406
I have UK post codes in the following formats
A1
AA1
A11
AA11

I need to extract just the letters in order to look up the city. In excel I just do this with checking if the 2nd digit is a number using ISNUMBER....simple. I am a newbie to powerpivot, but have tried every trick to get the same function to work without sucess.

The problem is when you use MID on this data it doesn't recognise the 2nd digit as a number and thinks it is text. I tried to use VALUE on the 2nd character, but then throws an error if the character is actually text. I tried to use an IF statement, but doesn't like one value being TEXT and the other being a NUMBER!!!!

Must be an easy solution!!!!

Thanks

Mike
 

ruve1k

Board Regular
Joined
Aug 31, 2008
Messages
171
When a mathematical operation is performed on a numeric text character (e.g. "3") then it will coerce the text into a number (e.g. 3). So by negating the result of MID([Primary Post Code],2,1) one of two things will happen:

  1. If the 2nd character is numeric text then it'll convert it into a number so ISERROR will return FALSE.
  2. If the 2nd character is NOT numeric text then it'll return an error and ISERROR will return TRUE.
The TRUE or FALSE is then coerced into a number when it is added to 1. So the parameter of the LEFT function will either be 1+FALSE = 1 or 1+TRUE =2.
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

masplin

Active Member
Joined
May 10, 2010
Messages
406
Ah so you are testing if -3 is acceptable whereas -M isn't.

Perfect thanks a lot.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,741
Messages
5,524,563
Members
409,585
Latest member
Aftab Anwar Yousaf Zai

This Week's Hot Topics

Top