Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
Introduction: I have 10 dynamic web queries that depend on the value of a cell. Once I quered the 10 queries, I append them them. Until here no problem, everything works. In theory those 10 web queries habe the same structure
( https://finance.yahoo.com/quote/AAPL/history?period1=1608768000&period2=1664928000&interval=1wk&filt... ) , the dynamic part is the ticker symbol (i write it in an excel cell) and the variable part is the unix timestamps that vary according to cell values (preset by me) to download different intervals of prices.
The 10 queries together can scrape a maximum of 19 years of data (arbitrary decision), so, if a company has less than 19 years of data some of these queries will present the error (for example aapl doesn't present errors because has more than 20 years of price data, but visa presents errors because if less than 19 years of data
😞 Expression.Error: The column 'Date' of the table wasn't found.
Details:
Date
For me its fine because if there's no data in these periods its logical that it doesnt retreive any data. But the problem appears when the new appended query that i create is coded including all the queries (including those that rbing errrors), so it doesnt work anymore.
The potential solutions that i thought about it are 2:
-OPTION 1: Create all the possible sources and through an if statement, retreive and combine the ones that doesnt bring errors and has the largest number of rows using some kind of if when error...
let
Source = Table.Combine({#"Table 0", #"Table 0 (2)", #"Table 0 (3)", #"Table 0 (4)", #"Table 0 (5)", #"Table 0 (6)", #"Table 0 (7)", #"Table 0 (8)", #"Table 0 (9)", #"Table 0 (10)"})
Source2 = Table.Combine({#"Table 0", #"Table 0 (2)", #"Table 0 (3)", #"Table 0 (4)", #"Table 0 (5)", #"Table 0 (6)", #"Table 0 (7)", #"Table 0 (8)", #"Table 0 (9)"})
Source3 = Table.Combine({#"Table 0", #"Table 0 (2)", #"Table 0 (3)", #"Table 0 (4)", #"Table 0 (5)", #"Table 0 (6)", #"Table 0 (7)", #"Table 0 (8)"})
Source4 = Table.Combine({#"Table 0", #"Table 0 (2)", #"Table 0 (3)", #"Table 0 (4)", #"Table 0 (5)", #"Table 0 (6)", #"Table 0 (7)"})
Source5 = Table.Combine({#"Table 0", #"Table 0 (2)", #"Table 0 (3)", #"Table 0 (4)", #"Table 0 (5)", #"Table 0 (6)"})
... up until it only combines the first 2 tables...
in
Source (Here is where the code with if statement is needed)
-OPTION 2: use some code to conditionally combine (append) those queries that don't bring error.
-OPTION 3: maybe someone has better alternative open to suggestions.
TY, I would upload the excel file but i haven't seen the option for uploading it...
Looks like you will need to add a bunch of conditional checks. Example:
let
Source = ...,
HasDateColumn = Source[Date]? <> null,
...,
SomeLaterStep = if HasDateColumn then <<Code for Date column existing>> else <<Code for no Date Column>>,
...
in
LastStep