Forum Discussion
How to use Html.Table properly?
- 5 years ago
If you connect to this as a web page, then you use the "Extract table using examples" tool. This returns code like this:
Html.Table( Source, {{"Column1", "TABLE > * > TR > :nth-child(1)"}, {"Column2", "TABLE > * > TR > :nth-child(2)"}, {"Column3", "TABLE > * > TR > :nth-child(3)"}, {"Column4", "TABLE > * > TR > :nth-child(4)"}, {"Column5", "TABLE > * > TR > :nth-child(5)"}}, [RowSelector="TABLE > * > TR"] )You can then promote headers to get
Now I'm trying to figure out how to use that tool without connecting to a website...
For reference, I found this article useful:
https://www.thepoweruser.com/2018/05/14/new-web-scraping-experience-in-power-bi-power-query-using-css-selectors/
If you connect to this as a web page, then you use the "Extract table using examples" tool. This returns code like this:
Html.Table(
Source,
{{"Column1", "TABLE > * > TR > :nth-child(1)"},
{"Column2", "TABLE > * > TR > :nth-child(2)"},
{"Column3", "TABLE > * > TR > :nth-child(3)"},
{"Column4", "TABLE > * > TR > :nth-child(4)"},
{"Column5", "TABLE > * > TR > :nth-child(5)"}},
[RowSelector="TABLE > * > TR"]
)You can then promote headers to get
Now I'm trying to figure out how to use that tool without connecting to a website...
For reference, I found this article useful:
https://www.thepoweruser.com/2018/05/14/new-web-scraping-experience-in-power-bi-power-query-using-css-selectors/
It works beautifully!!!
It is weird, but it adds an extra line containing the same descriptions that are available in the headers. Instead of 5 rows as output, I have 6, where the first one contains the same values already available in the headers. The only change I did is to replace the Source by a column:
= Table.AddColumn(#"Changed Type", "Info Table", each Html.Table([Customer Information], ...).