Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Breaking down postcodes

Featured Replies

I need our postcode to display in the correct order. I've broken the first part down into 2 fields so I can sort on the text and numbers, but I need to sort the second part of the postcode too.

The UK postcode format is usually TTNN TNN, however then first part can consist of just one letter or just one number. There is always a space in between the two parts.

What is "the correct order"?

  • Author

What I was thinking of doing was breaking the poscode field into 4 different calculated fields. So the text field, Poscode holding BR23 7TB would become...

BR (text field)

23 (numeric field)

7 (numeric field)

TB (text field)

I could then sort on these fields to ensure the actual postcode field in sorted correctly.

You haven't answered my question.

  • Author

You haven't answered my question.

The correct order for BR23 3TU would be..

BR - ascending

23 - ascending

3 - ascending

TU - ascending

This would ensure that BR1 is not followed by BR12 but BR2 etc. and the same for the second part of the postcode.

OK, then wouldn't it be sufficient to insert a zero after the first one or two alpha characters when they are followed by a single digit? That is "BR12 3TU" would remain unchanged, while "BR1 3TU" would be turned into "BR01 3TU".

Edited by Guest

  • Author

Yes, not a problem, but what I looking for is a calculation to scan the existing postcodes and break them down.

I am afraid I don't follow you. What would be the purpose of breaking it into four calculation fields, when it can be done by a single one? Not to mention that sorting by one field is more efficient than by four separate ones.

  • Author

ok, so how do I sort on just part of a field and how do I sort the numbers when they are currently text?

I presume what comment is getting at is that you don't need 4 additional fields. You only need one, Post Code Sort. That field will have the calculation that will return the post code in a sortable format.

It's not clear how a single letter in the first part of the code should sort, but I'd assume it should sort above any double letter. B23 sorts before BA11?

Let([

PostCode = Upper(table::field);

first = LeftWords(PostCode;1);

second = Rightwords(PostCode;1);

lets = filter(first;"ABCDEFGHIJKLMNOPQRSTUVWXYZ");

lets = Left(lets & 0;2);

nums = filter(first;"0123456789");

nums = Right(0& nums;2);

result = lets & nums & second

];

result

)

PS: Got distracted and posted later than I intended...This was in response to post #341074.

Edited by Guest

  • Author

Added this calc field. It concatenates the postcode but they do not display in the correct numerical order when you sort on this field.

Could you provide a specific example? Like, these codes sort in this order, when they should sort in this order?

  • Author

Sort order is back up the thread.

The correct order for BR23 3TU would be..

BR - ascending

23 - ascending

3 - ascending

TU - ascending

This would ensure that BR1 is not followed by BR12 but BR2 etc. and the same for the second part of the postcode.

I believe DJ's calculation should provide that. If you're seeing something else, it may be due to incorrect implementation (make sure the result type is Text) or something that I am missing. If the latter, I will keep missing it unless you show it me.

  • Author

Oops! It was me. Yes, it does work.

Thanks for all your help.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.