Uri.Parts

Updated on

Uri.Parts is a Power Query M function that extracts the parts of an input absoluteUri as a record, containing values such as Scheme, Host, Port, Path, Query, Fragment, UserName, and Password. The function returns a record with the various parts of the input absoluteUri.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Uri.Parts( absoluteUri as text ) as record

Description

Returns the parts of the input absoluteUri as a record, containing values such as Scheme, Host, Port, Path, Query, Fragment, UserName and Password.

Examples

Find the parts of the absolute URI “www.adventure-works.com”.

Uri.Parts( "www.adventure-works.com" )

 /* Output: 
[
    Scheme = "http",
    Host = "www.adventure-works.com",
    Port = 80,
    Path = "/",
    Query = [],
    Fragment = "",
    UserName = "",
    Password = ""
]
 */ 

Decode a percent-encoded string.

// Output: "+money$"
let
    UriUnescapeDataString = ( data as text ) as text => Uri.Parts( "http://contoso?a=" & data )[Query][a]
in
    UriUnescapeDataString( "%2Bmoney%24" )

Other functions related to Uri.Parts are:

BI Gorilla Youtube Channel

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/uri-parts