For God so loved the world, that He gave His only begotten Son, that all who believe in Him should not perish but have everlasting life
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

618 lines
22 KiB

  1. # Calculation Engine - Formula Function Reference
  2. ## Function Reference
  3. ### Database Functions
  4. #### DAVERAGE
  5. The DAVERAGE function returns the average value of the cells in a column of a list or database that match conditions you specify.
  6. ##### Syntax
  7. ```
  8. DAVERAGE (database, field, criteria)
  9. ```
  10. ##### Parameters
  11. **database** The range of cells that makes up the list or database.
  12. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  13. **field** Indicates which column of the database is used in the function.
  14. Enter the column label as a string (enclosed between double quotation marks), such as "Age" or "Yield," or as a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  15. **criteria** The range of cells that contains the conditions you specify.
  16. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  17. ##### Return Value
  18. **float** The average value of the matching cells.
  19. This is the statistical mean.
  20. ##### Examples
  21. ```php
  22. $database = array(
  23. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
  24. array( 'Apple', 18, 20, 14, 105.00 ),
  25. array( 'Pear', 12, 12, 10, 96.00 ),
  26. array( 'Cherry', 13, 14, 9, 105.00 ),
  27. array( 'Apple', 14, 15, 10, 75.00 ),
  28. array( 'Pear', 9, 8, 8, 76.80 ),
  29. array( 'Apple', 8, 9, 6, 45.00 ),
  30. );
  31. $criteria = array(
  32. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
  33. array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
  34. array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
  35. );
  36. $worksheet->fromArray( $criteria, NULL, 'A1' )
  37. ->fromArray( $database, NULL, 'A4' );
  38. $worksheet->setCellValue('A12', '=DAVERAGE(A4:E10,"Yield",A1:B2)');
  39. $retVal = $worksheet->getCell('A12')->getCalculatedValue();
  40. // $retVal = 12
  41. ```
  42. ##### Notes
  43. There are no additional notes on this function
  44. #### DCOUNT
  45. The DCOUNT function returns the count of cells that contain a number in a column of a list or database matching conditions that you specify.
  46. ##### Syntax
  47. ```
  48. DCOUNT(database, [field], criteria)
  49. ```
  50. ##### Parameters
  51. **database** The range of cells that makes up the list or database.
  52. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  53. **field** Indicates which column of the database is used in the function.
  54. Enter the column label as a string (enclosed between double quotation marks), such as "Age" or "Yield," or as a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  55. **criteria** The range of cells that contains the conditions you specify.
  56. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  57. ##### Return Value
  58. **float** The count of the matching cells.
  59. ##### Examples
  60. ```php
  61. $database = array(
  62. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
  63. array( 'Apple', 18, 20, 14, 105.00 ),
  64. array( 'Pear', 12, 12, 10, 96.00 ),
  65. array( 'Cherry', 13, 14, 9, 105.00 ),
  66. array( 'Apple', 14, 15, 10, 75.00 ),
  67. array( 'Pear', 9, 8, 8, 76.80 ),
  68. array( 'Apple', 8, 9, 6, 45.00 ),
  69. );
  70. $criteria = array(
  71. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
  72. array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
  73. array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
  74. );
  75. $worksheet->fromArray( $criteria, NULL, 'A1' )
  76. ->fromArray( $database, NULL, 'A4' );
  77. $worksheet->setCellValue('A12', '=DCOUNT(A4:E10,"Height",A1:B3)');
  78. $retVal = $worksheet->getCell('A12')->getCalculatedValue();
  79. // $retVal = 3
  80. ```
  81. ##### Notes
  82. In MS Excel, The field argument is optional. If field is omitted, DCOUNT counts all records in the database that match the criteria. This logic has not yet been implemented in PHPExcel.
  83. #### DCOUNTA
  84. The DCOUNT function returns the count of cells that aren’t blank in a column of a list or database and that match conditions that you specify.
  85. ##### Syntax
  86. ```
  87. DCOUNTA(database, [field], criteria)
  88. ```
  89. ##### Parameters
  90. **database** The range of cells that makes up the list or database.
  91. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  92. **field** Indicates which column of the database is used in the function.
  93. Enter the column label as a string (enclosed between double quotation marks), such as "Age" or "Yield," or as a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  94. **criteria** The range of cells that contains the conditions you specify.
  95. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  96. ##### Return Value
  97. **float** The count of the matching cells.
  98. ##### Examples
  99. ```php
  100. $database = array(
  101. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
  102. array( 'Apple', 18, 20, 14, 105.00 ),
  103. array( 'Pear', 12, 12, 10, 96.00 ),
  104. array( 'Cherry', 13, 14, 9, 105.00 ),
  105. array( 'Apple', 14, 15, 10, 75.00 ),
  106. array( 'Pear', 9, 8, 8, 76.80 ),
  107. array( 'Apple', 8, 9, 6, 45.00 ),
  108. );
  109. $criteria = array(
  110. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
  111. array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
  112. array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
  113. );
  114. $worksheet->fromArray( $criteria, NULL, 'A1' )
  115. ->fromArray( $database, NULL, 'A4' );
  116. $worksheet->setCellValue('A12', '=DCOUNTA(A4:E10,"Yield",A1:A3)');
  117. $retVal = $worksheet->getCell('A12')->getCalculatedValue();
  118. // $retVal = 5
  119. ```
  120. ##### Notes
  121. In MS Excel, The field argument is optional. If field is omitted, DCOUNTA counts all records in the database that match the criteria. This logic has not yet been implemented in PHPExcel.
  122. #### DGET
  123. The DGET function extracts a single value from a column of a list or database that matches conditions that you specify.
  124. ##### Syntax
  125. ```
  126. DGET(database, field, criteria)
  127. ```
  128. ##### Parameters
  129. **database** The range of cells that makes up the list or database.
  130. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  131. **field** Indicates which column of the database is used in the function.
  132. Enter the column label as a string (enclosed between double quotation marks), such as "Age" or "Yield," or as a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  133. **criteria** The range of cells that contains the conditions you specify.
  134. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  135. ##### Return Value
  136. **mixed** The value from the selected column of the matching row.
  137. #### Examples
  138. ```php
  139. $database = array(
  140. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
  141. array( 'Apple', 18, 20, 14, 105.00 ),
  142. array( 'Pear', 12, 12, 10, 96.00 ),
  143. array( 'Cherry', 13, 14, 9, 105.00 ),
  144. array( 'Apple', 14, 15, 10, 75.00 ),
  145. array( 'Pear', 9, 8, 8, 76.80 ),
  146. array( 'Apple', 8, 9, 6, 45.00 ),
  147. );
  148. $criteria = array(
  149. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
  150. array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
  151. array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
  152. );
  153. $worksheet->fromArray( $criteria, NULL, 'A1' )
  154. ->fromArray( $database, NULL, 'A4' );
  155. $worksheet->setCellValue('A12', '=GET(A4:E10,"Age",A1:F2)');
  156. $retVal = $worksheet->getCell('A12')->getCalculatedValue();
  157. // $retVal = 14
  158. ```
  159. ##### Notes
  160. There are no additional notes on this function
  161. #### DMAX
  162. The DMAX function returns the largest number in a column of a list or database that matches conditions you specify.
  163. ##### Syntax
  164. ```
  165. DMAX(database, field, criteria)
  166. ```
  167. ##### Parameters
  168. **database** The range of cells that makes up the list or database.
  169. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  170. **field** Indicates which column of the database is used in the function.
  171. Enter the column label as a string (enclosed between double quotation marks), such as "Age" or "Yield," or as a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  172. **criteria** The range of cells that contains the conditions you specify.
  173. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  174. ##### Return Value
  175. **float** The maximum value of the matching cells.
  176. ##### Examples
  177. ```php
  178. $database = array(
  179. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
  180. array( 'Apple', 18, 20, 14, 105.00 ),
  181. array( 'Pear', 12, 12, 10, 96.00 ),
  182. array( 'Cherry', 13, 14, 9, 105.00 ),
  183. array( 'Apple', 14, 15, 10, 75.00 ),
  184. array( 'Pear', 9, 8, 8, 76.80 ),
  185. array( 'Apple', 8, 9, 6, 45.00 ),
  186. );
  187. $criteria = array(
  188. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
  189. array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
  190. array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
  191. );
  192. $worksheet->fromArray( $criteria, NULL, 'A1' )
  193. ->fromArray( $database, NULL, 'A4' );
  194. $worksheet->setCellValue('A12', '=DMAX(A4:E10,"Profit",A1:B2)');
  195. $retVal = $worksheet->getCell('A12')->getCalculatedValue();
  196. // $retVal = 105
  197. ```
  198. ##### Notes
  199. There are no additional notes on this function
  200. #### DMIN
  201. The DMIN function returns the smallest number in a column of a list or database that matches conditions you specify.
  202. ##### Syntax
  203. ```
  204. DMIN(database, field, criteria)
  205. ```
  206. ##### Parameters
  207. **database** The range of cells that makes up the list or database.
  208. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  209. **field** Indicates which column of the database is used in the function.
  210. Enter the column label as a string (enclosed between double quotation marks), such as "Age" or "Yield," or as a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  211. **criteria** The range of cells that contains the conditions you specify.
  212. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  213. ##### Return Value
  214. **float** The minimum value of the matching cells.
  215. ##### Examples
  216. ```php
  217. $database = array(
  218. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
  219. array( 'Apple', 18, 20, 14, 105.00 ),
  220. array( 'Pear', 12, 12, 10, 96.00 ),
  221. array( 'Cherry', 13, 14, 9, 105.00 ),
  222. array( 'Apple', 14, 15, 10, 75.00 ),
  223. array( 'Pear', 9, 8, 8, 76.80 ),
  224. array( 'Apple', 8, 9, 6, 45.00 ),
  225. );
  226. $criteria = array(
  227. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
  228. array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
  229. array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
  230. );
  231. $worksheet->fromArray( $criteria, NULL, 'A1' )
  232. ->fromArray( $database, NULL, 'A4' );
  233. $worksheet->setCellValue('A12', '=DMIN(A4:E10,"Yield",A1:A3)');
  234. $retVal = $worksheet->getCell('A12')->getCalculatedValue();
  235. // $retVal = 6
  236. ```
  237. ##### Notes
  238. There are no additional notes on this function
  239. #### DPRODUCT
  240. The DPRODUCT function multiplies the values in a column of a list or database that match conditions that you specify.
  241. ##### Syntax
  242. ```
  243. DPRODUCT(database, field, criteria)
  244. ```
  245. ##### Parameters
  246. **database** The range of cells that makes up the list or database.
  247. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  248. **field** Indicates which column of the database is used in the function.
  249. Enter the column label as a string (enclosed between double quotation marks), such as "Age" or "Yield," or as a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  250. **criteria** The range of cells that contains the conditions you specify.
  251. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  252. ##### Return Value
  253. **float** The product of the matching cells.
  254. ##### Examples
  255. ```php
  256. $database = array(
  257. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
  258. array( 'Apple', 18, 20, 14, 105.00 ),
  259. array( 'Pear', 12, 12, 10, 96.00 ),
  260. array( 'Cherry', 13, 14, 9, 105.00 ),
  261. array( 'Apple', 14, 15, 10, 75.00 ),
  262. array( 'Pear', 9, 8, 8, 76.80 ),
  263. array( 'Apple', 8, 9, 6, 45.00 ),
  264. );
  265. $criteria = array(
  266. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
  267. array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
  268. array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
  269. );
  270. $worksheet->fromArray( $criteria, NULL, 'A1' )
  271. ->fromArray( $database, NULL, 'A4' );
  272. $worksheet->setCellValue('A12', '=DPRODUCT(A4:E10,"Yield",A1:B2)');
  273. $retVal = $worksheet->getCell('A12')->getCalculatedValue();
  274. // $retVal = 140
  275. ```
  276. ##### Notes
  277. There are no additional notes on this function
  278. #### DSTDEV
  279. The DSTDEV function estimates the standard deviation of a population based on a sample by using the numbers in a column of a list or database that match conditions that you specify.
  280. ##### Syntax
  281. ```
  282. DSTDEV(database, field, criteria)
  283. ```
  284. ##### Parameters
  285. **database** The range of cells that makes up the list or database.
  286. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  287. **field** Indicates which column of the database is used in the function.
  288. Enter the column label as a string (enclosed between double quotation marks), such as "Age" or "Yield," or as a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  289. **criteria** The range of cells that contains the conditions you specify.
  290. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  291. ##### Return Value
  292. **float** The estimated standard deviation of the matching cells.
  293. ##### Examples
  294. ```php
  295. $database = array(
  296. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
  297. array( 'Apple', 18, 20, 14, 105.00 ),
  298. array( 'Pear', 12, 12, 10, 96.00 ),
  299. array( 'Cherry', 13, 14, 9, 105.00 ),
  300. array( 'Apple', 14, 15, 10, 75.00 ),
  301. array( 'Pear', 9, 8, 8, 76.80 ),
  302. array( 'Apple', 8, 9, 6, 45.00 ),
  303. );
  304. $criteria = array(
  305. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
  306. array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
  307. array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
  308. );
  309. $worksheet->fromArray( $criteria, NULL, 'A1' )
  310. ->fromArray( $database, NULL, 'A4' );
  311. $worksheet->setCellValue('A12', '=DSTDEV(A4:E10,"Yield",A1:A3)');
  312. $retVal = $worksheet->getCell('A12')->getCalculatedValue();
  313. // $retVal = 2.97
  314. ```
  315. ##### Notes
  316. There are no additional notes on this function
  317. #### DSTDEVP
  318. The DSTDEVP function calculates the standard deviation of a population based on the entire population by using the numbers in a column of a list or database that match conditions that you specify.
  319. ##### Syntax
  320. ```
  321. DSTDEVP(database, field, criteria)
  322. ```
  323. ##### Parameters
  324. **database** The range of cells that makes up the list or database.
  325. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  326. **field** Indicates which column of the database is used in the function.
  327. Enter the column label as a string (enclosed between double quotation marks), such as "Age" or "Yield," or as a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  328. **criteria** The range of cells that contains the conditions you specify.
  329. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  330. ##### Return Value
  331. **float** The estimated standard deviation of the matching cells.
  332. ##### Examples
  333. ```php
  334. $database = array(
  335. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
  336. array( 'Apple', 18, 20, 14, 105.00 ),
  337. array( 'Pear', 12, 12, 10, 96.00 ),
  338. array( 'Cherry', 13, 14, 9, 105.00 ),
  339. array( 'Apple', 14, 15, 10, 75.00 ),
  340. array( 'Pear', 9, 8, 8, 76.80 ),
  341. array( 'Apple', 8, 9, 6, 45.00 ),
  342. );
  343. $criteria = array(
  344. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
  345. array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
  346. array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
  347. );
  348. $worksheet->fromArray( $criteria, NULL, 'A1' )
  349. ->fromArray( $database, NULL, 'A4' );
  350. $worksheet->setCellValue('A12', '=DSTDEVP(A4:E10,"Yield",A1:A3)');
  351. $retVal = $worksheet->getCell('A12')->getCalculatedValue();
  352. // $retVal = 2.65
  353. ```
  354. ##### Notes
  355. There are no additional notes on this function
  356. #### DSUM
  357. The DSUM function adds the numbers in a column of a list or database that matches conditions you specify.
  358. ##### Syntax
  359. ```
  360. DSUM(database, field, criteria)
  361. ```
  362. ##### Parameters
  363. **database** The range of cells that makes up the list or database.
  364. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  365. **field** Indicates which column of the database is used in the function.
  366. Enter the column label as a string (enclosed between double quotation marks), such as "Age" or "Yield," or as a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  367. **criteria** The range of cells that contains the conditions you specify.
  368. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  369. ##### Return Value
  370. **float** The total value of the matching cells.
  371. ##### Examples
  372. ```php
  373. $database = array(
  374. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
  375. array( 'Apple', 18, 20, 14, 105.00 ),
  376. array( 'Pear', 12, 12, 10, 96.00 ),
  377. array( 'Cherry', 13, 14, 9, 105.00 ),
  378. array( 'Apple', 14, 15, 10, 75.00 ),
  379. array( 'Pear', 9, 8, 8, 76.80 ),
  380. array( 'Apple', 8, 9, 6, 45.00 ),
  381. );
  382. $criteria = array(
  383. array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
  384. array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
  385. array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
  386. );
  387. $worksheet->fromArray( $criteria, NULL, 'A1' )
  388. ->fromArray( $database, NULL, 'A4' );
  389. $worksheet->setCellValue('A12', '=DMIN(A4:E10,"Profit",A1:A2)');
  390. $retVal = $worksheet->getCell('A12')->getCalculatedValue();
  391. // $retVal = 225
  392. ```
  393. ##### Notes
  394. There are no additional notes on this function
  395. #### DVAR
  396. Not yet documented.
  397. #### DVARP
  398. Not yet documented.