Import data from spreedsheet with multiple web links

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
SKU Data
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added SKUtext" = Table.AddColumn(Source, "SKUtext", each Text.PadStart(Text.From([SKU]),8,"0")),
#"Invoked Custom Function" = Table.AddColumn(#"Added SKUtext", "fnSKUdata", each fnSKUdata([SKUtext])),
#"Expanded fnSKUdata" = Table.ExpandTableColumn(#"Invoked Custom Function", "fnSKUdata", {"Product", "Description", "Price"}, {"Product", "Description", "Price"})
in
#"Expanded fnSKUdata"



fnSKUdata

(SKU) =>
let
Source = Lines.FromBinary(Web.Contents("https://www.motionindustries.com/productDetail.jsp?sku=" & SKU)),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Ignore),
#"Filtered Rows" = Table.SelectRows(#"Converted to Table", each Text.Contains([Column1], "<h1>") or Text.Contains([Column1], "<h2 class=""short-description"">") or Text.Contains([Column1], "<span class=""product-detail-uom"">")),
#"Extracted Text Between Delimiters" = Table.TransformColumns(#"Filtered Rows", {{"Column1", each Text.BetweenDelimiters(_, ">", "<", 0, 0), type text}}),
#"Transposed Table" = Table.Transpose(#"Extracted Text Between Delimiters"),
#"Renamed Columns" = Table.RenameColumns(#"Transposed Table",{{"Column1", "Product"}, {"Column2", "Description"}, {"Column3", "Price"}}),
#"Replaced Value" = Table.ReplaceValue(#"Renamed Columns","$","",Replacer.ReplaceText,{"Price"}),
#"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Product", type text}, {"Description", type text}, {"Price", Currency.Type}})
in
#"Changed Type"



SKU SKUtext Product Description Price
 
Upvote 0
Source

= Excel.CurrentWorkbook(){[Name="Table1"]}[Content]

Added SKUtext

= Table.AddColumn(Source, "SKUtext", each Text.PadStart(Text.From([SKU]),8,"0"))

Invoked Custom Function

"new column name"
fnSKUdata
"function Query"
fnskudata
"sku optional"
skutext

= Table.AddColumn(#"Added SKUtext", "fnSKUdata", each fnSKUdata([SKUtext]))


Expanded fnSKUdata

= Table.ExpandTableColumn(#"Invoked Custom Function", "fnSKUdata", {"Product", "Description", "Price"}, {"Product", "Description", "Price"})
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top