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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Extract Postal Area from UK Postcode

Hi all

 

For a long time I have been using an Excel formula to convert the first half of a UK postcode into its respective postal area code. For example, NE34 become NE.

 

It looks like this, where A2 contains the "NE34", for example: 

 

=LEFT(A2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))-1)

 

Could anyone please advise a DAX equivalent? The MIN function seems to operate differently and I'm stumped.

 

Thanks

1 ACCEPTED SOLUTION
jthomson
Solution Sage
Solution Sage

I'd look to do this in a couple of steps - first grab the first two characters using LEFT([yourpostcodefieldname],2), then I'd look to handle the cases where your postcode just has the one letter afterwards - not sure on the best way to do that given there's ten options you want to look for and then remove

 

edit - searched a bit and this has been asked previously, try having a look at https://community.powerbi.com/t5/Desktop/UK-Post-Codes/td-p/247470

View solution in original post

2 REPLIES 2
Sarah87
Regular Visitor

Hi I've been trying to use this as per the comments but everytime i enter this expression it gives me various error codes? Brand new to this so apologies if I'm doing somehting silly. Any help you can share would be greatly appreciated, thanks.

jthomson
Solution Sage
Solution Sage

I'd look to do this in a couple of steps - first grab the first two characters using LEFT([yourpostcodefieldname],2), then I'd look to handle the cases where your postcode just has the one letter afterwards - not sure on the best way to do that given there's ten options you want to look for and then remove

 

edit - searched a bit and this has been asked previously, try having a look at https://community.powerbi.com/t5/Desktop/UK-Post-Codes/td-p/247470

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.