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 dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I've been trying to get financial data (Income Statement, in particular) relating to public stocks from Alphavantage API, which is free.
https://www.alphavantage.co/documentation/
This is the M code i've used
Note: in row 3, it represent my personal computer path where I had created an Excel file with several stock tickers (i.e. AAPL, MSFT, TSLA), to which I could add tickers and the data in Power BI would extract additional financials automatically).
The later text in red (123....) represents the unique user/API key that you get for free from Alphavantage.
let
// Step 1: Load the list of unique identifiers from the Excel file
Source = Excel.Workbook(File.Contents("DummyTextWhereIusedMyPersonalDrive"), null, true),
SP500_Sheet = Source{[Item="SP500",Kind="Sheet"]}[Data],
// Step 2: Transform the data to a list of unique identifiers
UniqueIdentifiers = SP500_Sheet[Column1],
// Step 3: Define function to fetch data for a single company
GetCompanyData = (symbol as text) =>
let
Source = Json.Document(Web.Contents("https://www.alphavantage.co/query?function=INCOME_STATEMENT&symbol=" & symbol & "&apikey=12345678.....")),
#"Converted to Table" = Table.FromRecords({Source}),
#"Expanded quarterlyReports" = Table.ExpandListColumn(#"Converted to Table", "quarterlyReports"),
#"Expanded quarterlyReports1" = Table.ExpandRecordColumn(#"Expanded quarterlyReports", "quarterlyReports", {"fiscalDateEnding", "reportedCurrency", "grossProfit", "totalRevenue", "costOfRevenue", "costofGoodsAndServicesSold", "operatingIncome", "sellingGeneralAndAdministrative", "researchAndDevelopment", "operatingExpenses", "investmentIncomeNet", "netInterestIncome", "interestIncome", "interestExpense", "nonInterestIncome", "otherNonOperatingIncome", "depreciation", "depreciationAndAmortization", "incomeBeforeTax", "incomeTaxExpense", "interestAndDebtExpense", "netIncomeFromContinuingOperations", "comprehensiveIncomeNetOfTax", "ebit", "ebitda", "netIncome"}, {"fiscalDateEnding", "reportedCurrency", "grossProfit", "totalRevenue", "costOfRevenue", "costofGoodsAndServicesSold", "operatingIncome", "sellingGeneralAndAdministrative", "researchAndDevelopment", "operatingExpenses", "investmentIncomeNet", "netInterestIncome", "interestIncome", "interestExpense", "nonInterestIncome", "otherNonOperatingIncome", "depreciation", "depreciationAndAmortization", "incomeBeforeTax", "incomeTaxExpense", "interestAndDebtExpense", "netIncomeFromContinuingOperations", "comprehensiveIncomeNetOfTax", "ebit", "ebitda", "netIncome"})
in
#"Expanded quarterlyReports1",
// Step 4: Fetch data for each company in the list
CompanyData = List.Transform(UniqueIdentifiers, each GetCompanyData(_))
in
CompanyData
I keep getting the error "The column 'quarterlyReports' of the table wasn't found"
Which may be due to the fact that you get two lists / tables to choose from? (annualReports and quarterly reports)
I've tried multiple things trying to adjust the M code, but with no luck
I would highly appreciate if anyone's encountered this or know how to solve it
Best,
Martynas
Column1 (and you can see the error, which contains "quarterlyReport"). Unfortunately, I can't simply just remove errors, as when I do even though everything looks fine in PQ, when I apply and load I get the aforementioned error in Desktop.
Remove errors and then expand the column. Read about how to handle missing columns
I might be missunderstanding something, but as I just said, this approach didn't work as I've tried it
which columns do you see in the #"Converted to Table" step?
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
63 | |
59 | |
56 | |
38 | |
29 |
User | Count |
---|---|
82 | |
62 | |
45 | |
41 | |
40 |