Forum Discussion
UK Post Codes
Hi there,
I have some data that includes full post code, but I'm trying to find a way to just pull the postal area (either first letter or first 2 letters) into a new column.
I've looked at LEFT functions but couldn't figure out a way to do both.
Any ideas would be very much appreciated.
Hi Anonymous,
You can also achieve this via creating a calculated column using DAX:
POSTCODEnew = IF ( RIGHT ( LEFT ( 'UK Post Code'[POSTCODEold], 2 ), 1 ) IN { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }, LEFT ( 'UK Post Code'[POSTCODEold], 1 ), LEFT ( 'UK Post Code'[POSTCODEold], 2 ) )Best regards,
Yuliana Gu
12 Replies
- SivaManiResident Rockstar
Hi Anonymous,
Use Split column option (Edit Quries -> Split Column)
Regards,
Siva
- AnonymousNot applicable
This is a great option, but I want to leave the original data in one column, and then split into another, like below.
POSTCODEold POSTCODEnew
DW1 2ZZ DW
A22 2BB A
X33 5ZZ X
PB4 0XX PB
- SivaManiResident Rockstar
Simply create the duplicate column (Right click on POSTCODEold -> Duplicate Column). Split the column and delete the unwanted column.
That's it