mxls_db_query Function
Query MarketXLS databases with powerful formulas to get useful insights about price, volume, and fundamental data directly from our servers.
Function Structure
=MXLS_DB_Query("Database", "Symbol", "Query Type", "Aggregation", "Time Period")Parameters:
- Database: "historical" or "fundamental"
- Symbol: The stock symbol (e.g., "MSFT")
- Query Type: Volume, Open, High, Low, Close, Dividend, Split, Returns, etc.
- Aggregation: sum, average, max, min, variance, standard deviation
- Time Period: Number of days (e.g., "100") or date range (e.g., "2019-01-15^2020-06-21")
Historical Database Examples
To get the minimum low a symbol has reached in the last 100 days:
=MXLS_DB_Query("historical", "MSFT", "low", "min", "100")To get the average of daily returns in the last 100 days:
=MXLS_DB_Query("Historical", "MSFT", "returns", "average", 100)To get average daily returns between specific dates:
=MXLS_DB_Query("Historical", "MSFT", "returns", "average", "2019-01-15^2020-06-21")Date Format for Ranges
Fundamental Database Examples
You can calculate analytical functions on the MarketXLS database and quickly get values like Growth Rate (CAGR), trend, and average growth.
CAGR for 5 years of EPS:
=MXLS_DB_Query("Fundamental", "MSFT", "eps", "growth", "5y")Get the trend (increasing or decreasing) of revenue:
=MXLS_DB_Query("Fundamental", "MSFT", "revenue", "trend", "5y")Average of annual growth rates for revenue:
=MXLS_DB_Query("Fundamental", "MSFT", "revenue", "avggrowth", "5y")Sum of revenue over 5 years:
=MXLS_DB_Query("Fundamental", "MSFT", "revenue", "sum", "5y")Using Item Keys
The mxls_db_query function uses specific keys for fundamental items. For example, to work with Long Term Debt, use the key ltdebt:
Average growth of long term debt in the last 5 years:
=MXLS_DB_Query("Fundamental", "MSFT", "ltdebt", "avggrowth", "5y")Common Item Keys
Income Statement
- totRev - Total revenues
- opInc - Operating income
- netInc - Net income
- eps - Earnings per share
- ebit - EBIT
- ebitDa - EBITDA
Balance Sheet
- totAss - Total assets
- ltDebt - Long term debt
- totEq - Total equity
- cash - Cash and equivalents
- retEarn - Retained earnings
- totLia - Total liabilities
Cash Flow
- netCashOpAct - Net cash from operations
- netCashInvAct - Net cash from investing
- netCashFinAct - Net cash from financing
- freeCashFlow - Free cash flow
- cashFlow - Cash flow
Ratios & Metrics
- retStock - Return on equity
- retAss - Return on assets
- currRat - Current ratio
- quickRat - Quick ratio
- levRat - Leverage ratio