- SpreadJS Overview
- Getting Started
- JavaScript Frameworks
- Best Practices
- Features
- SpreadJS Designer
- SpreadJS Designer Component
- SpreadJS Collaboration Server
- Touch Support
-
Formula Reference
- Formula Overview
-
Formula Functions
- Barcode Functions
- Compatibility Functions
- Database Functions
- Date and Time Functions
- Engineering Functions
- Financial Functions
- Information Functions
- Logical Functions
- Lookup and Reference Functions
- Math and Trigonometric Functions
-
Statistical Functions
- AVEDEV
- AVERAGE
- AVERAGEA
- AVERAGEIF
- AVERAGEIFS
- BETA.DIST
- BETA.INV
- BINOM.DIST
- BINOM.DIST.RANGE
- BINOM.INV
- CHISQ.DIST
- CHISQ.DIST.RT
- CHISQ.INV
- CHISQ.INV.RT
- CHISQ.TEST
- CONFIDENCE.NORM
- CONFIDENCE.T
- CORREL
- COUNT
- COUNTA
- COUNTBLANK
- COUNTIF
- COUNTIFS
- COVARIANCE.P
- COVARIANCE.S
- DEVSQ
- EXPON.DIST
- F.DIST
- F.DIST.RT
- F.INV
- F.INV.RT
- F.TEST
- FINV
- FISHER
- FISHERINV
- FORECAST
- FREQUENCY
- GAMMA
- GAMMA.DIST
- GAMMA.INV
- GAMMALN
- GAMMALN.PRECISE
- GAUSS
- GEOMEAN
- GROUPBY
- GROWTH
- HARMEAN
- HYPGEOM.DIST
- INTERCEPT
- KURT
- LARGE
- LINEST
- LOGEST
- LOGNORM.DIST
- LOGNORM.INV
- MAX
- MAXA
- MAXIFS
- MEDIAN
- MIN
- MINA
- MINIFS
- MODE.MULT
- MODE.SNGL
- NEGBINOM.DIST
- NORM.DIST
- NORM.S.DIST
- NORM.S.INV
- NORMINV
- PEARSON
- PERCENTOF
- PERCENTILE.EXC
- PERCENTILE.INC
- PERCENTRANK.EXC
- PERCENTRANK.INC
- PERMUT
- PERMUTATIONA
- PHI
- PIVOTBY
- POISSON.DIST
- PROB
- QUARTILE.EXC
- QUARTILE.INC
- RANK.AVG
- RANK.EQ
- RSQ
- SKEW
- SKEW.P
- SLOPE
- SMALL
- STANDARDIZE
- STDEV.P
- STDEV.S
- STDEVA
- STDEVPA
- STEYX
- T.DIST
- T.DIST.2T
- T.DIST.RT
- T.INV
- T.INV.2T
- T.TEST
- TREND
- TRIMMEAN
- VAR.P
- VAR.S
- VARA
- VARPA
- WEIBULL.DIST
- Z.TEST
- Sparkline Functions
- Text Functions
- Web Functions
- RegEx Functions
- Other Functions
- Import and Export Reference
- Frequently Used Events
- API Documentation
- Release Notes
(Showing Draft Content)
PERCENTOF
This function is used to calculate the percentage of a subset of data relative to the entire dataset. It is particularly useful when combined with the GROUPBY and PIVOTBY functions to return percentages.
Syntax
PERCENTOF(data_subset, data_all)
Arguments
The function has following arguments.
Argument | Description |
|---|---|
data_subset (Required) | The values in the subset of data you want to analyze. |
data_all (Required) | The values that make up the entire set. |
Example
PERCENTOF(Sales_2019, Total_Sales)
The following code shows the usage of PERCENTOF function on a set of data.
// Allow the Dynamic Array to True
spread.options.allowDynamicArray = true;
spread.setSheetCount(3);
let sheet3 = spread.getSheet(2);
sheet3.name("PERCENTOF Function");
let data2 = [
["Product", "Sales"],
["Bib-Shorts", 7600],
["Bike Racks", 56100],
["Bottom Brack", 2100],
["Brakes", 11100],
["Gloves", 55900],
["Lights", 59600],
["Locks", 74800],
["Shorts", 48300],
["Socks", 9700],
["Tights", 61400],
["Vests", 7000],
["Wheels", 48500]
]
// Sheet3 - PERCENTOF Function
sheet3.setArray(0,0, data2);
sheet3.tables.add("table3",0,0, data2.length,2, GC.Spread.Sheets.Tables.TableThemes.medium2);
sheet3.setValue(1,8, "Bib-Shorts, Bike Racks and % of all");
sheet3.setFormatter(2,8, "0.00%");
sheet3.setFormula(2,8, "=PERCENTOF(B2:B3,B2:B13)");