Html.Table
Accessing DataExtracts data from HTML content into a table using CSS selectors to define columns.
Syntax
Html.Table(html as any, columnNameSelectorPairs as list, optional options as nullable record) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
html | any | Yes | The HTML content to parse. Can be a text value or binary (e.g., from Web.Contents or Web.BrowserContents). |
columnNameSelectorPairs | list | Yes | A list of two-element lists, where each inner list is {columnName as text, cssSelector as text}. The CSS selector is evaluated for each row to extract the cell value. |
options | record | No | An optional record with options. Supports RowSelector (text) to define a CSS selector for determining rows. |
Return Value
table — A table where each column is populated by evaluating the corresponding CSS selector against the HTML content.
Remarks
How it works: The The columnNameSelectorPairs parameter: Each entry is a two-element list CSS selector support: Standard CSS selector syntax is supported — element selectors ( Attribute extraction: To extract an HTML attribute rather than the element's text content, use an attribute selector pattern: appending Authentication: Compatibility note: ```powerquery ```powerquery ```powerquery ```powerqueryHtml.Table extracts structured data from HTML content by evaluating CSS selectors, giving you precise control over which elements become rows and what each column contains. Unlike Web.Page, which automatically detects elements,
Html.Table can target any HTML structure — including lists, card grids, or any other custom markup — as long as you can identify the elements with CSS selectors.RowSelector option defines what constitutes a "row" in the HTML document. Power Query finds all elements matching the row selector, then for each row element evaluates each CSS selector in columnNameSelectorPairs relative to that row element to extract the cell value. The inner text of the matched element becomes the cell value by default.{columnName, cssSelector}. The column name is a text label for the output column; the CSS selector extracts the cell value from within each row element. If no element matches the selector for a given row, the cell value is null.td, span), class selectors (.price), ID selectors (#total), attribute selectors ([data-id]), descendant combinators (div.card p.title), sibling combinators, and pseudo-classes like :nth-child() and :first-child.[attributeName] to the selector returns the attribute value instead of the inner text. For example, "a[href]" returns the href value of the matched anchor element.Html.Table does not make HTTP requests — it only parses HTML that you provide. Authentication is handled by whichever function fetches the HTML (Web.Contents, Web.BrowserContents, File.Contents, etc.). Query folding is not supported.Html.Table is not available in Power BI Service cloud refresh (it requires a gateway) or in Excel Online.Examples
Example 1: Extract columns from a styled HTML table using class selectors
let
Html = Web.Contents("https://example.com/products"),
Result = Html.Table(
Html,
{
{"Product", "td.product-name"},
{"Price", "td.product-price"},
{"Stock", "td.product-stock"}
},
[RowSelector = "table.product-list tr"]
)
in
ResultExample 2: Extract link text and URLs from a list
let
Html = Web.Contents("https://example.com/resources"),
Links = Html.Table(
Html,
{
{"Label", "a"},
{"URL", "a[href]"}
},
[RowSelector = "ul.resource-list li"]
)
in
LinksExample 3: Parse a raw HTML string directly
let
RawHtml = "<table><tr><td>Apple</td><td>1.20</td></tr><tr><td>Banana</td><td>0.50</td></tr></table>",
Result = Html.Table(
RawHtml,
{
{"Fruit", "td:nth-child(1)"},
{"Price", "td:nth-child(2)"}
},
[RowSelector = "tr"]
)
in
ResultExample 4: Chain with Web.BrowserContents for JavaScript-rendered pages
let
Html = Web.BrowserContents(
"https://example.com/dynamic-data",
[WaitFor = [Element = "table.results"]]
),
Data = Html.Table(
Html,
{
{"Name", "td.name"},
{"Score", "td.score"}
},
[RowSelector = "table.results tr.data-row"]
)
in
DataCompatibility