Quantcast
Channel: Power Query topics
Viewing all articles
Browse latest Browse all 31097

How to handle a single error on web based table navigation

$
0
0

I have have built two functions to call data from a web based source using a list of 200 different url parts. The url basically just ends in a company name. I needed 2 functions as the html paths were slightly different for different parts of the data i wanted. 

 

This all works great apart from one company  . The first function is fine, but the 2nd function is giving the error " There weren't enough elements in the enumeration to complete the operation."  It seems there just aren't as many navigation levels on this item as all the others. 

 

So my first choice is just to elimiate the whole row, but is there any way to keep the row with the data retruned by the other function and replace the error with a null or something?  Essentially trying to expand the table from the 2nd function blows up, but just for one row

 

This is my code with thr Added.Custom1 being the issue on expansion

 

let
    Source = Excel.Workbook(File.Contents("U:\Dropbox\Limerston\Crawford\CRO Companies.xlsx"), null, true),
    CRO_Company_Table = Source{[Item="CRO_Company",Kind="Table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(CRO_Company_Table,{{"Company", type text}, {"Address", type text}, {"Search", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Web_Main([Search])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"#(lf)Website#(lf)", "#(lf)Headquarters#(lf)", "#(lf)Laboratories#(lf)", "#(lf)Company Type#(lf)", "#(lf)Certifications#(lf)", "#(lf)Year Established#(lf)", "#(lf)No. of Employees#(lf)"}, {"#(lf)Website#(lf)", "#(lf)Headquarters#(lf)", "#(lf)Laboratories#(lf)", "#(lf)Company Type#(lf)", "#(lf)Certifications#(lf)", "#(lf)Year Established#(lf)", "#(lf)No. of Employees#(lf)"}),
    #"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Custom", each Web_Description([Search])),
    #"Sorted Rows" = Table.Sort(#"Added Custom1",{{"Company", Order.Ascending}})
in
    #"Sorted Rows"

Thanks

Mike.


Viewing all articles
Browse latest Browse all 31097

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>