<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Extracting UK Postcodes in to new column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extracting-UK-Postcodes-in-to-new-column/m-p/1930815#M41918</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset which contains full addresses but I need the postcode extracted in to a seperate column. I have managed this in excel using this formula:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;=RIGHT(SUBSTITUTE(B2," ","*",LEN(B2)-LEN(SUBSTITUTE(B2," ",""))-1),LEN(B2)-FIND("*",SUBSTITUTE(B2," ","*",LEN(B2)-LEN(SUBSTITUTE(B2," ",""))-1)))&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The address is in the following format:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT size="2"&gt;221b Baker St, London, NW1 6XE&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have searched through the forums and so far cant find anything that meets the requirement. I have seen his done by breaking out the address using the delimiter functions in the Quary Editor and then combining the two parts of the postcode to create a full postcode but ideally I would like a column for the full address and a seperate one for the postcode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope someone can help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Richard.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jun 2021 13:28:43 GMT</pubDate>
    <dc:creator>richardburling</dc:creator>
    <dc:date>2021-06-30T13:28:43Z</dc:date>
    <item>
      <title>Extracting UK Postcodes in to new column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extracting-UK-Postcodes-in-to-new-column/m-p/1930815#M41918</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset which contains full addresses but I need the postcode extracted in to a seperate column. I have managed this in excel using this formula:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;=RIGHT(SUBSTITUTE(B2," ","*",LEN(B2)-LEN(SUBSTITUTE(B2," ",""))-1),LEN(B2)-FIND("*",SUBSTITUTE(B2," ","*",LEN(B2)-LEN(SUBSTITUTE(B2," ",""))-1)))&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The address is in the following format:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT size="2"&gt;221b Baker St, London, NW1 6XE&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have searched through the forums and so far cant find anything that meets the requirement. I have seen his done by breaking out the address using the delimiter functions in the Quary Editor and then combining the two parts of the postcode to create a full postcode but ideally I would like a column for the full address and a seperate one for the postcode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope someone can help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Richard.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 13:28:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extracting-UK-Postcodes-in-to-new-column/m-p/1930815#M41918</guid>
      <dc:creator>richardburling</dc:creator>
      <dc:date>2021-06-30T13:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting UK Postcodes in to new column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extracting-UK-Postcodes-in-to-new-column/m-p/1931781#M41959</link>
      <description>&lt;P&gt;Wikipedia introduces postcodes in the UK in detail; interesting enough, regular expressions for validation are also provided.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom" target="_blank"&gt;https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, it's fairly easy to extract postcodes with above-mentioned regex,&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    RE = (regex as text, str as text) =&amp;gt;
    let
        html =
            "&amp;lt;script&amp;gt;
            var regex = " &amp;amp; regex &amp;amp; ";
            var str = """ &amp;amp; str &amp;amp; """;
            var res = str.match(regex);
            document.write(res)
            &amp;lt;/script&amp;gt;",
        res = Web.Page(html)[Data]{0}[Children]{0}[Children]{1}[Text]{0}
    in res,

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XcyxCsIwFAXQX7lkztBEcE9t6aA4WCRCyBDJoxTTF0hT/H2Lg4P74TgntFZPtOFFBWOVuGSOmSWuVuH46IWXTqgGXX7zzNNOCtGPYbTKQBvzZUOhUHHb1pVS+pf2pFocukGi5ykFjhJ3nitFnPc35kV4/wE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Addr = _t]),
    #"Added Custom" = Table.AddColumn(Source, "P.C.", each RE("/[A-Z]{1,2}[0-9][A-Z0-9]? ?[0-9][A-Z]{2}/gi", [Addr]))
in
    #"Added Custom"&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 22:06:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extracting-UK-Postcodes-in-to-new-column/m-p/1931781#M41959</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2021-06-30T22:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting UK Postcodes in to new column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extracting-UK-Postcodes-in-to-new-column/m-p/1932515#M41976</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="250150" data-lia-user-login="CNENFRNL" class="lia-mention lia-mention-user"&gt;CNENFRNL&lt;/a&gt;&amp;nbsp;thanks for taking the time and making a suggestion. Unfortuntaley this isnt what I am looking for.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I think a spreadsheet with 2000+ addresses and would like to seperate the postcode from the address string. Essentially I need the Query Editor to extract only the postcode from the address string and put it in a new column. It cant have an spaces or commas in the column either. Obvioulsy postcodes come in various characters length so its not just a case of using the 'Text.end([Address],8)' as this brings back all the last eight characters.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that makes sense.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 07:45:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extracting-UK-Postcodes-in-to-new-column/m-p/1932515#M41976</guid>
      <dc:creator>richardburling</dc:creator>
      <dc:date>2021-07-01T07:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting UK Postcodes in to new column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extracting-UK-Postcodes-in-to-new-column/m-p/4374024#M173669</link>
      <description>&lt;P&gt;This is just what I want, how do i make if fit my scenario?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 16:02:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extracting-UK-Postcodes-in-to-new-column/m-p/4374024#M173669</guid>
      <dc:creator>geebers</dc:creator>
      <dc:date>2025-01-21T16:02:30Z</dc:date>
    </item>
  </channel>
</rss>

