Uri.Parts

URI

Parses an absolute URI into a record of its component parts.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Uri.Parts(absoluteUri as text) as record

Parameters

NameTypeRequiredDescription
absoluteUritextYesThe absolute URI to parse.

Return Value

recordA record containing the URI components: Scheme, Host, Port, Path, Query, Fragment, and more.

Remarks

Uri.Parts breaks an absolute URI into its components and returns them as a record with the following fields:

| Field | Type | Description | |---|---|---| | Scheme | text | The protocol (e.g., "https"). | | Host | text | The hostname (e.g., "www.example.com"). | | Port | number | The port number (e.g., 443). | | Path | text | The path segment (e.g., "/api/data"). | | Query | record | Query string parameters as a record (e.g., [page = "1"]). | | Fragment | text | The fragment identifier after #. |

This function is useful for extracting specific parts of URLs stored in your data — for example, pulling the domain from a list of web addresses, or extracting query-string parameters.

Examples

Example 1: Parse a URL into components

let
    Url = "https://api.example.com:8080/data/items?category=electronics&page=2",
    Parts = Uri.Parts(Url)
in
    #table(
        {"Component", "Value"},
        {
            {"Scheme", Parts[Scheme]},
            {"Host", Parts[Host]},
            {"Port", Text.From(Parts[Port])},
            {"Path", Parts[Path]}
        }
    )
Result
Component
Value
1Schemehttps
2Hostapi.example.com
3Port8080
4Path/data/items

Example 2: Extract domain from URLs in a table

let
    Source = #table({"Page"}, {{"https://shop.example.com/products/123"}, {"https://blog.example.com/posts/hello"}}),
    Added = Table.AddColumn(Source, "Domain", each Uri.Parts([Page])[Host], type text)
in
    Added
Result
Page
Domain
1https://shop.example.com/products/123shop.example.com
2https://blog.example.com/posts/helloblog.example.com

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks