Print Page  
FORMULA FUNCTIONS / CROSS SECTIONAL
FMedian("formula" [,scope, excl_zero])
Full Description
Calculates the median value of the formula within each scope. FMedian works like this:
  • The formula in quotes is evaluated for all the stocks in each scope. The formula could be a single factor, like "MktCap" or more complex like "Close(0)/Close(10)".
  • The results are placed in an array
  • The array is sorted. If your scope is within a sector, for example, multiple sorts are executed for each sector.
  • The median value of the formula is returned for all the stocks with non-N/A values. If an odd number of stocks exist in the array, it returns the middle value otherwise it averages the values of the two middle stocks.

Parameters

formula: any valid stock formula
scope: determines how stocks are grouped before median is calculated (see below)
exclude_zero: when set to TRUE 0 values are discarded (handy for factors like Yield). Default is FALSE

Examples:

Find stocks with market caps higher than industry median

MktCap > FMedian("MktCap",#Industry)

Find stocks with PE's less than the SP500 Median PE

PEExclXorTTM < FMedian("PEExclXorTTM ",#SP500)

Make two groups: stocks that have a yield and stocks that do not. Return stocks that have higher market cap in the respective group

SetVar(@Group,Yield>0)
SetVar(@median,FMedian("MktCap",#GroupVar))
MktCap > @median

Scope Parameter


Values Stocks ETFs Description
#AllYYOperates on current universe
#Previous1YYOperates on the results from previous rule
#GroupVar2YYOperates on groups based on value of variable @Group
--------------------------- For Stocks Only ---------------------------
#SP500YOperates within the SP500 universe
#SectorYOperates within each Sector of current universe
#SubSectorYOperates within each SubSector of current universe
#IndustryYOperates within each Industry of current universe
#SubIndustryYOperates within each SubIndustry of current universe
--------------------------- For ETFs Only ------------------------------
#FamilyYOperates within each ETF Family
#AssetClassYOperates within each ETF Class
#RegionYOperates within each ETF Region
#CountryYOperates within each ETF Country
#MethodYOperates within each ETF Method
#StyleYOperates within each ETF Style
#SizeYOperates within each ETF Size
#ETFSectorYOperates within each ETF Sector
1Available only in the Screener and Custom Universe
2Not available in Ranking Systems