Forum Discussion
Why Am I Getting Two Different Results From One Constant Source?
- 8 years ago
- Anonymous8 years ago
Thanks again v-chuncz-msft. This seems to be working okay:
let GetData = () => if List.Contains(Table.ColumnNames(Web.Page(Web.Contents("https://webapps.MyDomain/path/req_search.cfm?page=AP")){1}[Data]), "Details") then
Table.RemoveColumns(Web.Page(Web.Contents("https://webapps.MyDomain/path/req_search.cfm?page=AP")){1}[Data],{"Details"}) else @GetData(), ShowData = GetData() in ShowData - Anonymous8 years ago
v-chuncz-msft, I went back and changed my query to use try-otherwise, with the recursive function structured as below, and it worked this way too. So I'm marking your original response as a solution. Thanks yet again for your help.
let GetData = () => try Table.RemoveColumns(Web.Page(Web.Contents("https://webapps.MyDomain/path/req_search.cfm?page=AP")){1}[Data],{"Details"}) otherwise @GetData(),
ShowData = GetData() in ShowData
Well, I guess another question would be, if you go to the web page in a browser and click refresh a bunch of times, does it sometimes come back blank?
I just tried refreshing the web page a bunch of times and it always came up just fine. Separately though, I did try something else that yielded a result I found interesting.
I refreshed my query, then I clicked on the table in the Data column of the Source and got the not desired resulting table of columns; but then I waited a moment and, without refreshing the query, I clicked on the table in the Data column of the Source again and got the desired resulting table of columns. So I'm thinking I need a delay before I navigate to the table of columns via Source{1}[Data]. I'm guessing I need to use Function.InvokeAfter(), but I'm not sure how to use it with Source{1}[Data]. I tried Function.InvokeAfter(Source{1}[Data], #duration(0,0,0,5)) but I got the error:
Expression.Error: We cannot convert a value of type Table to type Function.
Details:
Value=Table
Type=Type
I also attempted to use a function to get around the error, base on some of Chris Webb's blogs but I'm not sure I did it right, because I still got the intermittent problem.
Would you agree that I might need a delay, and if so, how might you add it?
- v-chuncz-msft8 years agoCommunity Support
- Anonymous8 years agoNot applicable
Thanks v-chuncz-msft. I tried two different recursive functions. One uses try-otherwise and would theoretically keep refetching the table till it could find and and delete the column named Details, and the other uses if-then-else and would keep refetching the table till it could find the column named Details (if it's there, it's the right table). Both functions gave me the same error: Expression.Error: Evaluation resulted in a stack overflow and cannot continue.
When I substituted Kind for Details, both functions worked fine, because they fetched the second result table (from my original question's examples)...probably on their first attempt...and that second result table has a column named Kind.
Any other ideas?
My function attempts' code are:
let Source = Web.Page(Web.Contents("https://MyDomain/path/req_search.cfm?page=AP")), GetData = (DataSource) => let DataSet = DataSource{1}[Data], RemoveIt = try Table.RemoveColumns(DataSet,{"Details"}) otherwise @GetData(DataSource) in RemoveIt, ShowData = GetData(Source) in ShowData...and...
let Source = Web.Page(Web.Contents("https://MyDomain/path/req_search.cfm?page=AP")), GetData = (DataSource) => let DataSet = DataSource{1}[Data], CheckForColumn = if List.Contains(Table.ColumnNames(DataSet), "Details") then
Table.RemoveColumns(DataSet,{"Details"}) else @GetData(DataSource) in CheckForColumn, ShowData = GetData(Source) in ShowData- v-chuncz-msft8 years agoCommunity Support