Copyright ©New Cloud Technologies Ltd., 2016 - 2021 This text (hereinafter, the ”Material”) is informational documentation on MyOffice software, licensed under the terms of https://myoffice.ru/en/eula/ or a later version. The rightholder of the Material is New Cloud Technologies Ltd. You can not use the contents of the file in any way without New Cloud Technologies, Ltd. written permission. To obtain such a permit, you should contact New Cloud Technologies, Ltd. at http://ncloudtech.com/contact.html. 1 Limitation of liability The information provided here and now by the representatives of New Cloud Technologies Ltd. cannot be interpreted as a commitment or promise to develop, implement or deliver any software product, feature or capability. A commitment or promise to develop, implement, or deliver any software product, feature, or capability is only valid if it is confirmed by the respective contract. The upcoming software products’ release date, feature set, means of distribution, and the suggested price may differ from what is discussed here and now. The plans presented are based on what we know today, and this may change due to the expansion of our abilities or any unforeseen changes in the market. New Cloud Technologies Ltd. reserves the right to change the development plans at any time and without notifying anyone of such changes. All product names, logos, and trademarks mentioned in this document belong to their respective owners. The trademark "MyOffice" belongs to New Cloud Technologies Ltd. All product names, logos, and trademarks referred to in this document shall belong to their owners and have been used here in accordance with the provisions of applicable laws. Nothing in these terms shall be construed under any circumstances as direct or indirect provision of a license or right to use the trademarks, logos or service marks used herein. Any unauthorized use of these trademarks, logos or service marks without the written permission of their owner is strictly prohibited. 2 Contents I Copyright . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Limitation of liability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 General functionality 4 1 Understanding formulas 5 1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.2 Formula structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.2.1 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.2.2 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.2.3 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.2.4 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.3 Value types and properties . . . . . . . . . . . . . . . . . . . . . . . . 16 1.3.1 Value types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 1.3.2 Value properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 1.3.3 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 1.4 Complex numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 1.5 Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2 Working with cells and ranges 26 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.2 A1 and R1C1 styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.3 Relative and absolute references . . . . . . . . . . . . . . . . . . . . . 27 2.4 Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 3 2.4.1 Explicit intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.4.2 Implicit intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.5 Array formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 2.6 Data-tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.7 Database functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3 Cell formatting 46 3.1 Introduction to cell number formatting . . . . . . . . . . . . . . . . . . 47 3.2 Custom formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 3.2.1 Number tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 3.2.2 Date and time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.2.3 Additional tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 3.2.4 Formats with multiple rules . . . . . . . . . . . . . . . . . . . . . . 56 3.3 Autodetect mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.4 Autodetect in formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 4 Localization 65 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 4.2 Locale identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 5 Pivot tables 5.1 74 Pivot table overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 5.1.1 Creating and editing a report . . . . . . . . . . . . . . . . . . . . . 75 5.1.2 Filtration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 5.1.3 Changing the aggregate function . . . . . . . . . . . . . . . . . . . 76 5.1.4 Load only features . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 5.2 Create and edit pivot tables . . . . . . . . . . . . . . . . . . . . . . . . 79 5.2.1 Preparing your data . . . . . . . . . . . . . . . . . . . . . . . . . . 79 5.2.2 Inserting a pivot table . . . . . . . . . . . . . . . . . . . . . . . . . 79 5.2.3 Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 5.2.4 Updating and deleting pivot tables . . . . . . . . . . . . . . . . . . 84 4 5.3 Pivot grouping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 5.3.1 Grouped text items . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 5.3.2 Grouped dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 5.3.3 Grouped numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 5.4 Filtering data in a pivot table . . . . . . . . . . . . . . . . . . . . . . . 89 5.4.1 Applying filters to Rows and Columns fields . . . . . . . . . . . . . 89 5.4.2 Adding fields as Filters . . . . . . . . . . . . . . . . . . . . . . . . . 90 5.5 Aggregate functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 5.6 Additional calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 5.7 Pivot table options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 5.8 Number formatting in pivot tables . . . . . . . . . . . . . . . . . . . . . 98 5.8.1 Automatic formatting based on your data source . . . . . . . . . . 98 5.8.2 Number formatting per field . . . . . . . . . . . . . . . . . . . . . . 100 II Description of functions 101 6 Mathematical functions 102 6.1 ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 6.2 ACOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 6.3 ACOSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 6.4 ACOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 6.5 ASIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 6.6 ATAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 6.7 ATAN2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 6.8 ATANH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 6.9 COSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 6.10 COTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 6.11 CSC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 6.12 CSCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 6.13 DEGREES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 5 6.14 EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 6.15 FACTDOUBLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 6.16 INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 6.17 LN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 6.18 LOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.19 LOG10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 6.20 PI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 6.21 POWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 6.22 PRODUCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 6.23 QUOTIENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 6.24 RAND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 6.25 ROUND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 6.26 ROUNDDOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 6.27 ROUNDUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 6.28 SEC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 6.29 SECH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 6.30 SINH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 6.31 SQRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 6.32 SQRTPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 6.33 SUBTOTAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 6.34 SUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 6.35 SUMIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 6.36 SUMIFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 6.37 SUMPRODUCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 6.38 SUMSQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 6.39 TANH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 7 Database functions 7.1 170 DSUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 8 Logical functions 174 6 8.1 AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 8.2 FALSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 8.3 IF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 8.4 IFERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 8.5 IFNA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 8.6 OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 8.7 SWITCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 8.8 TRUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 9 Date and time functions 187 9.1 DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 9.2 DATEVALUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 9.3 DAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 9.4 EDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 9.5 EOMONTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 9.6 HOUR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 9.7 ISOWEEKNUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 9.8 MINUTE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 9.9 MONTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 9.10 NOW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 9.11 TODAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 9.12 YEAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 10 Statistical functions 208 10.1 AVERAGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 10.2 COUNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 10.3 COUNTA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 10.4 COUNTBLANK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 10.5 COUNTIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 10.6 COUNTIFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 10.7 F.DIST.RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 7 10.8 F.DIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 10.9 FISHER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 10.10 LARGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 10.11 LINEST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 10.12 MAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 10.13 MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 10.14 NORM.DIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 10.15 RANK.EQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 10.16 SMALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 10.17 STDEV.S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 10.18 VAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 10.19 VARA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 10.20 VARPA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 11 Financial functions 248 11.1 COUPPCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 11.2 DOLLARDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 11.3 DOLLARFR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 11.4 IRR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 11.5 NPV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 11.6 PMT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 11.7 PV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 12 Text functions 268 12.1 ASC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 12.2 CLEAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 12.3 CODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 12.4 CONCATENATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 12.5 Conversion functions: JIS and DBCS . . . . . . . . . . . . . . . . . . 274 12.6 EXACT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 12.7 FIND and FINDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 8 12.8 LEFT and LEFTB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 12.9 LEN and LENB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 12.10 LOWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 12.11 MID and MIDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 12.12 PROPER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 12.13 RIGHT and RIGHTB . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 12.14 SEARCH and SEARCHB . . . . . . . . . . . . . . . . . . . . . . . . . 288 12.15 SUBSTITUTE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 12.16 TEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 12.17 TRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 12.18 UNICODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 12.19 UPPER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 13 Information functions 298 13.1 CELL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 13.2 INFO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 13.3 ISBLANK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 13.4 ISERR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 13.5 ISERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 13.6 ISEVEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 13.7 ISLOGICAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 13.8 ISNA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 13.9 ISNUMBER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 13.10 ISODD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 13.11 ISREF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 13.12 ISTEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 13.13 NA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 14 Reference functions 317 14.1 ADDRESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 14.2 AREAS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 9 14.3 CHOOSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 14.4 COLUMN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 14.5 COLUMNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 14.6 HLOOKUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 14.7 HYPERLINK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 14.8 INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 14.9 INDIRECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 14.10 LOOKUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 14.11 Vector Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 14.12 Array Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 14.13 MATCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 14.14 OFFSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 14.15 ROW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 14.16 ROWS 14.17 VLOOKUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 15 Engineering functions 345 15.1 COMPLEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 15.2 IMABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 A Alphabetic index 349 10 Part I General functionality 11 Chapter 1 Understanding formulas 12 Introduction Formulas allow you to perform different operations on values inside cells and fill your tables with automatically calculated data. In the following chapter, you will learn how formulas are built and calculated. Formula structure A formula is an expression entered after an equal sign (=). This expression can be composed of 28 different types of elements, which can be separated on functions, constants, references, operators, and empty arguments. Constants and references are also returned as the result of formulas. A formula can be entered either into the formula line or a cell and looks as follows: Operator Reference = EXP ()+4.4 + A1 Function Constant A valid formula must have at least one operand and cannot end with an operator except for unary percent. Otherwise, it is treated as text. The result of a formula depends on the values and operators supplied to it (more about this topic in section 1.3). Constants A constant is a value entered directly into a formula. Constants can be separated into the following types: • String • Number • Boolean • Error Multiple constants can be presented as an array. 13 String = “abc” A string is a sequence of characters enclosed in double quotes. Each string can be composed of characters from multiple writing systems because the editor uses UTF-8 encoding to present strings (more about encoding in section 1.5). Number A number can be entered into a formula in multiple forms. Below are the most frequently used ones. = 1.10 (Decimal) = 1 1/9 (F raction) = 1.10E + 00 (Scientif ic) Boolean A boolean can be presented as one of two constants: = T RU E = F ALSE Inside a formula that returns a number as a result, TRUE and FALSE are converted into 1 and 0 respectively. Thus, the expression below returns 1. = T RU E + F ALSE Error An error is usually returned as a formula result, but it can be used as a constant inside an expression, although such an expression returns the leftmost error as a result. A typed error is equivalent to a returned one. There are 8 types of errors: • #NULL! is returned when a range specified by a formula is not found. • #DIV/0! is returned when a formula contains division by zero. 14 • #VALUE! is returned when an argument type or quantity of arguments is invalid. • #REF! is returned when a formula contains an invalid reference. • #NAME? is returned when a named range or a function does not exist. • #NUM! is returned when a supplied number is invalid. • #N/A is returned when a referenced value is not found. • #GETTING_DATA is returned when an external reference is not valid, or the calculations are not yet processed. Array Array is a set of constants enclosed in curly brackets. Rows in arrays are separated by semicolons, and elements of rows are separated by commas: = {1, 2; 3, 4} References A formula argument can be a reference to a cell or a range, which can contain constants, references, and formulas. Our editor supports two ways of presenting references: A1 notation and R1C1 notation, with the first set as the default one. (More about referencing styles in section 2.2 of chapter 2.) By default, all references refer to cells from a current sheet. Another sheet can be specified by entering its name with an exclamation mark in the beginning of a reference. Cell address A cell address is usually composed of a column name, and a row number. = A1 A sheet can also be specified. = Sheet1!A1 15 Range address A range address is composed of two cell addresses separated by a colon. The first cell address refers to the top left corner of a selection, and the second refers to the bottom right corner. = A1 : B5 A sheet can also be specified. = Sheet1!A1 : B5 A range address can also refer to the same range on multiple sheets. In this case, multiple sheets are specified. = Sheet1!A1 : Sheet2!B5 or = Sheet1 : Sheet2!A1 : B5 Defined name A defined name is a named reference to a cell or a range. = M Y DEF IN EDN AM E Our editor does not allow to create defined names, however it supports the ones exported from other editors. A defined name can belong to a specific sheet or to a whole document. A defined name that belongs to a specific sheet must be specified with a sheet name on other sheets. = Sheet1!M Y DEF IN EDN AM E 16 Reference list A reference list can contain different types of references: cell addresses, range addresses, and defined names. Each reference must be separated from the next one with a comma. = A1, B2 : C3 If entered directly into a function, a reference list must be enclosed in parenthesis. = SU M (A1, B2 : C3) Operators Operators are used in formulas alongside with operands and affect formula results. They can be separated on 4 groups: • Arithmetic operators • Comparative operators • Text operators • Reference operators Arithmetic operators Arithmetic operations can be performed on numbers, booleans, arrays, and references to cells or ranges with only these types of constants. Important! The power operator Name Symbol Example Unary plus + = + + +1 Unary minus − = − − −1 Percent % = 1%%% Binary plus + =1+1 Binary minus − = C3 − −D5 Multiplication ∗ = A1 ∗ B5 Division / = 10/5 Power ˆ = 3ˆ3ˆ3 Priority () = (2 + 3) ∗ 6 (ˆ) is right-associative. The last example is equivalent to 327 . 17 Comparative operators Comparative operations can be performed on all types of constants and references. The result of these operations is usually a boolean. Name Symbol Example Equal = = #N U M ! = 0 Not equal <> = #N U M ! <> #V ALU E! Less < = T RU E < 1 Less or equal <= = 1 <= 1 Greater > = C3 > A1 Greater or equal >= = C3 >= 2 Concatenation operator The concatenation operator is the only text operator in our editor. It converts its operands into strings and connects them together into a new string. = T RU E & 1.1 The result of this formula is T RU E1.1. Reference operators Reference operations can be performed only on references and return references as a result. Union Union returns the smallest cell range that contains all cells referred by provided operands. Its operator coincides with the range operator, colon (:), because every cell range is in fact a union of two cells. = A1 : B2 : C3 : D4 Although, the expression above can be treated as a union of 2 cell ranges, it is in fact a union of 4 following cells: 18 A B C D E 1 2 3 4 5 The result is a minimal range that covers all cells referenced in the expression. Its address is A1:D4. A B C D E 1 2 3 4 5 Intersection Intersection returns a reference to cells that are presented in each of the supplied references. = A1 : B2 B1 : D3 The result of the operation is the B1:B2 range. A B C D E 1 2 3 4 The described intersection is called explicit intersection. You can learn more about it and implicit intersection in section 2.4 of chapter 2. 19 Functions A function is a predefined formula with an identifier. =SUM(1,1) A function always consists of an identifier and one or more arguments enclosed in parenthesis. An identifier is usually abbreviation of what the function does and can be typed in any letter case. Multiple arguments are separated from each other by a comma and can be required or optional. The required ones must stand before the optional ones. A function argument can be simple or composite. The first type provides a function with a single value. The second one provides a function with multiple values. All composite arguments are formed of simple ones. Simple argument =SUM(1,2,A1,B2) A simple argument can be a constant, a cell address, or a formula (unless it returns multiple values). It can also be empty. All calculations inside a function are performed on constants or empty arguments. If a function argument is a cell address, the editor performs calculations on the constant inside the referred cell. If a function argument is a formula, the editor performs calculations on its result. Constants Functions take different types of constants as arguments: • Number • String • Boolean • Error Each function has specific type restrictions, although they coincide for some functions. For example, SUM takes only numbers and booleans. Entering a wrong type of a constant as an argument generally results in the #VALUE! error. However, a function always returns the first encountered error, so supplying, for 20 example, a #DIV/0! error to a function results in a #DIV/0! error even if there is no division by 0. Empty argument =SUM(,) An empty argument is generally converted to 0 (in arithmetic functions) or an empty string (in text functions). Empty optional arguments do not have to be separated with a comma and are often converted to their own predefined values, which vary depending on the function. In the following example, the optional argument is converted to 1. =ADDRESS(1,2,) =ADDRESS(1,2) Both expressions return $A$1. =ADDRESS(1,2,0) This expression returns the #VALUE! error. Formulas inside functions =SUM(1,SUM(2,3),4) Formulas can also be used as arguments. They are called nested formulas and do not start with an equal sign. Composite argument A composite argument can be a simple array, a cell range, or a reference list. =MAX({1,2;3,4},{}) =SUM(A1:B2) =MAX(’Sheet1:Sheet2’!A1:B2) 21 =SUM(A1,B2:C4) Functions created in our editor always return single values. A composite value can only be received as a part of an exported document that contains an array formula or a function that returns a multi-valued result by default: {=LEN(A2:A4)} This function is entered as an array formula—enclosed in curly brackets. As a result, it takes an array of strings and returns an array of their lengths. 1 A B C Input Result 2 dollar 6 3 euro 4 4 pound 5 D 5 =MUNIT(3) This function returns an array by default. In this case, the result is a 3x3 matrix. A B C D 1 2 1 0 0 3 0 1 0 4 0 0 1 5 22 Value types and properties The result of a formula depends on the types of values it receives. This section describes value types that are used by the editor and how they behave in calculations. Value types All calculations inside the editor are performed on 5 types of values: 1. Number 2. String 3. Boolean 4. Error 5. Empty Each of these types, except for empty, can be a result of an expression and can have multiple properties (more about properties in subsection 1.3.2). Number = 1.1 The editor performs all calculations on integers and floating-point numbers, which can be presented as dates, fractions, and so on. Different ways of presenting numbers are called formats and are set by a specific property for each value. Below are examples of numbers in different formats: A B 1 Date 2 Fraction 3 Accounting ($ C 12/31/2006 1 1/2 23 1) D String = ”string” Values of this type are used in text operations and are returned as their results. They are also used to set value format inside cells and formulas. = ”31/12/2012” Numbers that are entered this way are actually strings, however they are processed inside arithmetical formulas the same way as regular numbers. Complex number = ”1i + 1” Complex numbers are always recognized as strings and cannot be operands of regular arithmetic expressions. There are designated functions for this type of values: IMSUM, IMPRODUCT and so on. They are called engineering functions. (You can learn more about complex numbers and engineering functions in section 1.4. To see the full list of engineering functions, go to section 15.) Boolean There are only two possible values of this type: TRUE and FALSE. Each of them can be an operand: = T RU E = F ALSE They are usually returned as a result of a logical expression: =1<0 = AN D(T RU E, 1) Empty Values of this type are used in the following scenarios: 24 • A formula refers to an empty cell. • An array element is not specified. (More about arrays in section 1.3.3.) • A function argument is not specified. In arithmetic expressions, an empty value is usually converted to 0. In text operations, it is converted to a zero-length string (""). Therefore, if a formula returns an empty value, it is also converted either into 0 or a zero-length string. For example: = SIN ( ) This expression returns zero. In some functions, optional arguments that receive empty values are converted to specific predefined values. For example: = P RODU CT (1, , ) This expression returns 1 because this function ignores empty values. Error #V ALU E! Values of this type are usually returned as a result of invalid expressions, but can also be used as operands. In most cases, an expression with errors within it returns the first encountered error as the result. For example: = #DIV /0! + 1 This expression returns #DIV/0! even though there is no division by zero. However, there are functions, such as ISERROR, that were designed to verify and manage errors. These functions do not return errors upon receiving them as arguments. Value properties The result of a formula depends not only on value type but also on value properties. There are two types of them: 1. Formatting 25 2. Hyperlink. Formatting This property is stored for every value. Upon entering a value or receiving it as a result, the editor always tries to set this property automatically. For example, upon receiving the following formula, the editor detects the Percentage format. = 10% + 1 A 1 B C 110% 2 In ambiguous cases, the editor sets the first detected format. For example, the following formula returns the result in the Fraction format (1 3/5). = 1 1/2 + 10% A 1 B C 1 3/5 2 Formatting can also be set manually by presenting a value as a string or using TEXT. = “12/12/2012” + 12 A B 1 C 12/24/2012 2 = T EXT (25%, 0.00) A 1 B C 0.25 2 Hyperlink This property is applied to values by a function of the same name. = HY P ERLIN K(”yahoo.com”, ”Y ahoo”) 26 The expression above returns the second string, which leads to the address specified in the first string. A B C 1 Link Address 2 Yahoo yahoo.com 3 4 Any operation on a value with the hyperlink property results in the property loss. For example, the formula in the A3 cell is = A2&”.com” A B 1 Label Address 2 Yahoo yahoo.com 3 Yahoo.com C 4 The result is a string without the hyperlink property. Arrays Multiple single values can compose an array, which can be specified in two ways. As a simple array: = {1, 2; 3, 4} As a reference: A B 1 1 2 2 3 4 Every reference is actually an array and is treated by the editor accordingly, although a single cell address inside a formula usually leads to the same result as a single constant. Most regular formulas and functions expect and return single values. To be able to process an array correctly, a regular formula must be presented as an array formula, which looks as follows: {= A1 : B2 + 1} 27 You can find more detailed information about array formulas in section 2.5 of chapter 2. There also other ways to resolve a formula with an array, and they also described in chapter 2. 28 Complex numbers This section describes complex numbers in our editor, how they can be obtained, and in what operations they can be used. Notation A complex number is a number that can be presented in form a+bi, where a and b are any real numbers, and i is the imaginary unit—a number which square is equal to -1. 1 + 2i The letter j can also be used as the imaginary unit in situations when the default notation is ambiguous. −1 − 2j In our editor, complex numbers are actually strings and are processed accordingly. Only engineering functions can perform arithmetic operations on them. Input methods A complex number can be obtained in 4 different ways: Description Formula Entered directly into a cell 23 + 23i Entered as a string inside a formula = “23 + 23i” Result 23 + 23i Received as a result of concatenation = “23” & “ + ” & “23i” Received as a result of a function = COM P LEX(23, 23, “i”) Engineering functions Every function that can perform calculations on complex numbers has an IM prefix in its name and does the same as its counterpart for real numbers. For example, IMSUM sums the supplied arguments. 29 A B C 1 Data Result 2 5+5i 11+2i 3 6-3i =IMSUM(A2,A3) You can find detailed descriptions of all engineering functions in chapter 15. Notes • A function can take multiple complex numbers in different notations (considering that it supports them). If the result is a complex number, it is returned with i as the imaginary unit. A B C 1 Data Result 2 1+1i -1-1i 3 -2-2j =IMSUM(A2,A3) • Functions designed for complex numbers can take real numbers as arguments. In such cases, they return the same results as their counterparts for real numbers. A 1 B C Data Result 2 12 3 24 36 =IMSUM(A2,A3) 30 Encoding Different applications can use different encodings to present text. As a result, importing a file from one application to another sometimes lead to undesired outcomes: words turn into unreadable strings of symbols, text operations do not work as expected, and so on. In this section, you can learn about encodings in general and how they affect our editor’s functionality. Overview Every written symbol that appears on a monitor is stored as a numerical value inside a computer. Different realizations of this process are called encodings. The oldest character encodings cover only one or several languages. To store each character, they use a single byte and are called single-byte character sets (SBCS). An example of an SBCS is ASCII (American Standard Code for Information Interchange), which was developed exclusively for the United States and covers only 128 symbols. Not all writing systems can be presented in an SBCS. For example, Chinese alphabet has thousands of letters, so most characters need more than a single byte of storage. One of the earliest solution to this problem was DBCS (double-byte character set), which uses 2 bytes to store each symbol. DBCS was one of many encodings that were designed for a specific set of language and were not compatible with the others. The Unicode standard was developed to define a single way of storing symbols from all existing writing systems. As a result, such encodings as UTF-8 and UTF-16 have appeared. Currently, UTF-8 is the most popular among them and other encodings. UTF-8 and DBCS functions Before the establishment of the Unicode standard, DBCS was widely used in Korea, China, and Japan. As a result, some table editors released and supported such functions as SEARCHB and FINDB, which were designed to work with DBCS–encoded text and counted each character as two bytes. In our editor, all texts are presented in UTF-8. This encoding is compatible with most of the older ones, so our editor can import text from any other editor without unexpected changes. As a result, conversion functions (JIS, DBCS, DBCS) return result without modification, and DBCS functions work identically to regular string functions (SEARCH, FIND and so on). DBCS functions are supported in our editor only to provide full compatibility with older documents. Below is the full list of these functions: 31 • SEARCHB • FINDB • LEFTB • RIGHTB • MIDB • LENB • JIS • DBCS • ASC 32 Chapter 2 Working with cells and ranges 33 Introduction Spreadsheets usually contain large amounts of data, which require special approaches different from the way you work with constants and single cells. In this chapter, you will learn about different types of data sets and how to work with them. A1 and R1C1 styles = A1 You should be familiar with this reference style from the previous chapter. Our editor uses A1 style by default. In this style, rows are labeled by numbers, and columns are labeled by letters. Therefore, a reference to a cell is composed of a column label and a row label in the order given. The table below illustrates cell labels in the A1 notation: A B C D 1 A1 B1 C1 D1 2 A2 B2 C2 D2 3 A3 B3 C3 D3 4 A4 B4 C4 D4 = R1C1 In the R1C1 reference style, both rows and columns are labeled by numbers. Therefore, a row number and a column number are specified in a cell reference. The table below illustrates cell labels in the R1C1 notation: 1 2 3 4 1 R1C1 R1C2 R1C3 R1C4 2 R2C1 R2C2 R2C3 R2C4 3 R3C1 R3C2 R3C3 R3C4 4 R4C1 R4C2 R4C3 R4C4 Relative and absolute references References in our editor can be absolute, relative, or mixed. An absolute one refers to a fixed cell on a table, and a relative one specifies how a referred cell is positioned to a reference. Mixed referencing allows to specify a relative row and a fixed column or vice versa. 34 When a relative or mixed reference moves to another cell, the referred cell adjusts accordingly. If an absolute reference moves to another cell, it continues to refer to the same cell. Operations that move references are copy/paste, cut/paste, and autofill. Both A1 and R1C1 notations allow to specify relative, absolute, and mixed references. Relative A1 notation The default A1 notation represents relative references. = A1 In the following table, the formula is entered into the B2 cell. A B 1 Data1 2 Data2 =A1 3 Data3 C D 4 This reference specifies a cell that is one row above it and one column to the left of it. In the table below, the reference is copied to the B3 cell and adjusts accordingly. A B 1 Data1 2 Data2 Data1 3 Data3 =A2 C D C D 4 A B 1 Data1 2 Data2 Data1 3 Data3 Data2 4 Absolute A1 notation = $A$1 An absolute A1 reference is presented with a dollar sign ($) before each of its parts (column and row labels). In the table below, the formula is entered into the B2 cell. 35 A B 1 Data1 2 Data2 =$A$1 3 Data3 C D 4 In the following table, the reference is copied to the B3 cell but continues to refer to the A1 cell. A B 1 Data1 2 Data2 Data1 3 Data3 =$A$1 C D C D 4 A B 1 Data1 2 Data2 Data1 3 Data3 Data1 4 Mixed A1 notation = $A1 A mixed reference is presented with a dollar sign ($) either before a column part or a row part. In the table below, the formula is entered into the B2 cell. A B 1 Data1 2 Data2 =$A1 3 Data3 C D 4 The formula in the B2 cell refers to a cell that is one row above it in the A column. In the following table, the reference is copied to the C4 cell and adjusts accordingly. 36 A B 1 Data1 2 Data2 Data1 3 Data3 4 C D =$A3 A B 1 Data1 2 Data2 Data1 3 Data3 4 C D Data3 Absolute R1C1 notation The default R1C1 notation represents absolute references. = R1C1 In the following table, the reference is copied from the R2C2 cell to the R3C2 cell but continues to refer to the old cell. 1 2 1 Data1 2 Data2 3 Data3 =R1C1 3 4 3 4 Data1 4 1 2 1 Data1 2 Data2 Data1 3 Data3 Data1 4 Relative R1C1 notation A relative R1C1 reference is presented with numbers enclosed in square brackets. Negative numbers indicate that the referred cell is to the top (for rows) and to the left (for columns) of the reference, and positive ones indicate that the referred cell is to the bottom and to the right of the reference. 37 = R[−1]C[−1] In the following table, the reference is copied from the R2C2 cell to the R3C2 cell. 1 2 3 1 Data1 2 Data2 3 Data3 =R[-1]C[-1] 4 Data1 4 1 2 3 1 Data1 2 Data2 Data1 3 Data3 Data2 4 4 The result is “Data2" because the reference changed its position, and now, the cell that is one row above it and one column left of it is the R2C1 cell. Mixed R1C1 notation = R1C[−2] In the following table, the reference is copied from the R2C3 cell to the R3C4 cell. 1 2 3 1 Data1 Data4 2 Data2 3 Data3 4 Data1 =R1C[-2] 4 1 2 1 Data1 Data4 2 Data2 3 Data3 3 4 Data1 Data4 4 The result is “Data4" because the reference specifies the first row cell that is two columns left of it. 38 Notes • By default, all references are relative. • Upon switching from one reference style to another, all references are converted to the chosen one. • A defined name can coincide with an A1 reference representation if the R1C1 style is chosen and the other way around. After style switch, such defined names remain without changes unless edited manually. • When a reference changes its position after insertion or deletion of rows and columns, it continues to refer to the same cell as before the changes. Although, its appearance adjusts to the changes. Before changes: A B 1 Data1 2 Data2 3 Data3 =A2 C D 4 A B C 1 Data1 2 Data2 3 Data3 Data2 D 4 After changes: A B C 1 2 Data1 3 Data2 4 Data3 Data2 5 39 D A B C 1 2 Data1 3 Data2 4 Data3 =A3 5 40 D Intersection This section describes explicit and implicit intersection and their behavior depending on the supplied operands. Explicit intersection = A1 : C3 A1 : A2 Explicit intersection returns one or more shared areas (a cell, a range, or a reference list) between supplied references. Its operator is a single space ( ). Notes • If the supplied references do not cross each other, the operation returns the #NULL! error. An explicit intersection of references from different sheets also results in this error. • If an intersection point is a range, the operation returns the #VALUE! error because it cannot put multiple values into a single cell. However, an intersection can be supplied to a function that processes multivalued arguments into a single-valued result (SUM, MAX, and so on). In such cases, the result will not be an error (see example #4). • Upon receiving a reference list, the operation calculates intersection for each of the elements. If at least one of the intersections leads to an error, the formula stops calculations and returns the received error. Examples 1. =2:2B:B A B C D E 1 2 1 2 3 4 5 3 4 In the example above, the 2:2 range represents a row, and the B:B range refers to a column. The formula returns 2 because the intersection point is the B2 cell. 41 2. = A1 : B2 B2 : D4 A B C D E 1 2 3 4 The formula returns 0 (zero) because the intersection point is the B2 cell, which is empty. 3. = A1 : B2 B1 : D4 A B C D E 1 2 3 4 The formula returns the #VALUE! error because the intersection point is a range. 4. = SU M (A2 : B3 B1 : D4) A B C D E 1 2 1 3 1 4 The result of this intersection is a range, but the formula does not return an error. It returns 2 because SUM processed two values into a single-cell result. 42 Implicit intersection Implicit intersection does not have a designated operator. It occurs automatically when a formula expects a single-valued argument but receives a range. The operation extends the cell with the formula horizontally or vertically until intersects the supplied range and returns the received shared point. The operation is mostly used with single-dimensional ranges. Intersecting a cell with a multidimensional range usually results in the #VALUE! error. Notes • Such functions as SUM and MAX process ranges as multiple single arguments and do not use implicit intersection. • If there is no intersection point, the operation returns the #VALUE! error. • Implicit intersection can occur if a formula and a supplied range are located on different sheets (example #6). • Intersecting a cell with a multidimensional range can return a valid result if the cell and the range are located on different sheets (example #7). Examples 1. The formula in the B2 cell is = D2 : D4 A B C D E 1 2 2 2 3 3 4 4 The B2 cell is extended horizontally until it intersects the D1:D4 range. The intersection point is the D2 cell, so the formula returns 2. 2. The formula in the B2 cell is = D1 : E4 43 A B C D E 1 2 #VALUE! 3 4 The D2:E4 range has more than one dimension, so the formula returns an error. 3. The formula in the B2 cell is = C3 : C4 A B C D E 1 2 #VALUE! 3 4 The supplied references do not have an intersection point, so the formula returns an error. 4. The formula in the B2 cell is = SIN (E1 : E4) A B C D E 1 2 0.909297427 2 3 3 4 4 The B2 cell is extended horizontally until it intersects the E2:E4 range. The intersection point is the E2 cell, so the formula returns the sine of 2. 5. The formula in the B2 cell is =D :D+E :E A B C D E 1 2 2 1 3 4 44 1 The formula intersects the B2 cell with the D:D range, then with the E:E range, and then sums the values from the two intersection points. 6. The formula in the B2 cell from Sheet2 is = Sheet1!A1 : A4 A B C A 1 Sheet1 1 2 1 2 3 2 3 4 3 4 B C Sheet2 1 7. The formula in the B2 cell from Sheet2 is = Sheet1!A2 : B4 A B C A 1 Sheet1 2 1 4 2 3 2 5 3 4 3 6 4 1 45 B C Sheet2 4 Array formulas In this section, you can learn about array formulas, and how they can be used in our editor. An array formula is a formula that expects an array as an argument and returns an array. Such formulas are enclosed in curly braces: {= C4 : D5} Most often, array formulas are used to specify a single behavior for multiple cells. For example, the following one is applied to all cells in the D2:E3 range: {= A2 : B3 + 1} A B C D E 1 Input Result 2 1 2 2 3 3 3 4 4 5 4 Our editor supports only imported array formulas, and they cannot be edited or reused in other cells. However, it is possible to edit cells from the ranges supplied to an array formula and receive corresponding results. Modified arrays as a result of array formulas Some editors require to specify the output range of an array formula. In tables imported from such editors, an array formula can return an array that is smaller or bigger than the one it actually received after calculations. Such cases are demonstrated in the following examples: Examples The specified output range (D2:E2) is smaller than the resulted array. {= A2 : B3} 46 A B C 1 Input 2 1 2 3 3 4 D E Result 1 2 4 The result of the expression is a 2x2 array, but the editor truncates it to fit into the specified output range. The specified output range (D2:E3) is larger than the resulted one-dimensional array. {= A2 : B2} A B 1 Input 2 1 C D E Result 2 3 1 2 1 2 4 The result of the expression is a 2x1 array, but the editor duplicated to it to fill a 2x2 range. {= SU M (A2 : B3)} A B C D E 1 Input Result 2 1 2 10 10 3 3 4 10 10 4 The result of the expression is an 1x1 array, but the editor duplicated it to fill the specified range. Only one-dimensional arrays can be duplicated to fill the output range. If the resulted array is multidimensional, odd cells are filled with #N/A errors (see the next example). The specified output range (D2:E4) is larger than the resulted multidimensional array. {= A2 : B3} A B C D E 1 Input Result 2 1 2 1 2 3 3 4 3 4 4 #N/A #N/A 47 Data-tables This section describes data tables and how they can be used in our editor. Definition and syntax A data table is a tablelike range that contains arranged arguments and corresponding results of a function with one or two variables. Data tables are mainly used in financial forecasting. A formula that defines data-table behavior is called data-table function. Cells with results of such a function cannot be edited unless with the whole table. However, you can change the function itself or its arguments to receive new results. Our editor does not support data-table functions, and converts them into regular formulas to provide the same results as the original data table. One-variable data tables One-variable data tables can be column- or row-oriented. In a column-oriented data table, arguments are listed in a column, and the function is located one row above and one column to the right of the first argument. A 1 B C D E F 10 2 =A1/10 3 4 5 0.5 5 50 5 6 100 10 7 In a row-oriented data table, arguments are listed in a row, and the function is located one row below and one column to the left of the first argument. A 1 B C D 10 2 3 4 =A1/10 5 50 100 0.5 5 10 5 48 E F Two-variable data table In a two-variable data table, arguments for one variable are listed in a row right of the function, and arguments for another variable are listed in a column below of the function. 1 A B 10 5 C D E F 2 3 =A1/B1 10 20 30 40 4 5 2 4 6 8 5 50 0.2 0.4 0.6 0.8 6 100 0.1 0.2 0.3 0.4 7 Data tables in our editor In our editor, data tables and data-table functions are converted to regular ranges and formulas. Consider the following example: 1 A B 10 5 C D E 2 3 50 1 2 3 4 5 5 10 15 5 10 10 20 30 6 The table below demonstrates converted formulas: 1 A B 10 5 C D E 2 3 50 1 2 3 4 5 =B3*A4 =C3*A4 =D3*A4 5 10 =B3*A5 =C3*A5 =D3*A5 6 All formulas in this table are independent. You can change the arguments to receive new results, however changing the formula in the A3 cell will not affect any other formulas inside the table. 49 Database functions In this section, you can learn about the family of database functions, their syntax, and usage. Definition Database functions are designed to work with database-like ranges, which contain column headers in the first row and corresponding data records in the following rows. All these functions start with D letter and resemble their counterparts for regular ranges in functionality (for example, DSUM resembles SUM). The difference between them is that database functions can ignore cells that do not satisfy specified conditions. All database functions take the following arguments, in the respective order: database—a range with records. field—the header of a column that contains values to be summed, multiplied, and so on. criteria—a range with database headers in the first row and conditions for the corresponding columns in the following rows. Criteria for database functions can contain multiple rows and columns. Conditions in one column are joined with OR logic, and conditions in one row are joined with AND logic. OR logic 1 2 3 4 5 A B C Model Price ($) Discount A1 >100 20% A2 <250 10% A3 >300 5% D AND logic Notes • field can be specified as a column number or a column header between double quotation marks. Number 1 matches the first column of database. • Database functions ignore letter case. • During calculations, database functions ignore cells under field if they contain text. 50 • If an empty range or a range with an empty second row is specified as criteria, all values under field are used in calculations. • Database functions support predicates (>,<, >=, <=, =, <>). • Database functions support wildcard characters in criteria that contain text. By default, a question mark (?) is treated as any single character and an asterisk (*) is treated as any sequence of characters. To use an actual question mark or asterisk in criteria, type a tilde (~) before the character. Usage Example =DSUM(database, field, criteria) DSUM calculates the sum of data that matches specified conditions. A B C D E 1 Name Engines Price ($) Flight Range (km) Result 2 Boeing 2 100000000 3 Boeing 4 300000000 4 Airbus 2 110000000 700 100000000 5 Airbus 4 280000000 13500 280000000 6 IL 4 180000000 13000 F 6000 400000000 13000 6000 7 8 Name Price ($) 9 Boeing >80000000 Flight Range (km) Flight Range (km) >5000 10 Airbus <8000 >14000 11 IL 12 1. Formula entered in the E2 cell is as follows: =DSUM(A1:C6, C1, A8:A9). As a result, the function calculates the sum of prices for the Boeing aircrafts specified in the dataset and returns $400000000. 2. Formula entered in the E3 cell is as follows: =DSUM(A1:D6, 4, A8:D9). As a result, the function sums flight ranges of Boeings that can fly more than 5000 km but less than 8000 km and cost less than $80000000. The function returns 6000 because only the first item matches the criteria. 51 3. Formula entered in the E4 cell is as follows: =DSUM(A1:D6, 3, A8:D10). The function calculates the sum of values in column C under the conditions specified in the A8:D10 range. The result is 100000000. 4. Formula entered in the E5 cell is as follows: =DSUM(A1:D6,"Price ($)",A8:D11). The function calculates the sum of values in column C (headed "Price") under the conditions specified in the A8:D11 range. The result is 280000000. 52 Chapter 3 Cell formatting 53 Introduction to cell number formatting Every number in our editor can be formatted in multiple ways. For example, in the table below, number 10 is formatted into a date. A B C D 1 2 1/9/1900 3 4 Formatted values are only decorations and do not affect calculations. For example, the date above is actually number of days that have passed since 12/30/1899 (the starting date in our editor) and is equal to 10, which can be checked with a simple formula. A B C 1 D A B C D 1 2 1/9/1900 2 1/9/1900 3 =B2-10 3 12/30/1899 4 4 Predefined and custom formats Together with Date there are 11 predefined formats in our editor: Name Description Example General Displays the number without changes. Number Displays the number with at least 2 decimal places. 12.10 Currency Displays the number with at least 2 decimal places and a currency sign. $12.10 Accounting Replicates Currency but puts a space before the currency sign and displays negative numbers in braces without a minus sign. 54 12.1 $ 12.10 ($ 12.10) Date Displays the number as a date. Time Displays the number as time. Date and time Displays the number as a date with time. Percentage 2:24:00 AM 1/11/1900 2:24 AM Displays the number as percentage (1=100%). Fraction Displays the number as a fraction. Scientific Displays the number in scientific notation. Text 1/11/1900 Displays the number as text. 1210.00% 12 1/10 1.21E+01 12.1 Custom formatting All predefined formats can be modified into custom ones with the help of special symbols called tokens. Currently, you cannot create custom formats in our editor, but you can import them from other applications. See Custom formatting. Autodetection mechanism Although you can always set number formatting manually, in most cases, the editor does this for you. It predicts the desired format based on what is typed into a cell whether its a single value or a formula. For example, entering 12/31/2001 into a cell results in Date format, and entering =10%+1 results in Percentage format. See Autodetect mechanism. 55 Custom formatting Custom formatting lets you modify predefined formats with the help of special symbols or combinations of symbols called tokens. The same token can specify different behavior depending on the other tokens that surround it. Load only: Currently, you cannot create formatting rules in our editor. You can only import them from other editors. You can also decorate your numbers with function TEXT. It takes the same tokens as the custom formatting mechanism but returns text and aligns it accordingly (to the left). Below, we will describe the tokens that can be recognized by the custom formatting mechanism of our editor. Number tokens These tokens allow to present numbers in different notations: as decimal numbers with adjustable decimal point, as fractions, and so on. Formatting rules with these tokens align formatted values to the right. Token Behavior If a digit is supplied # 0 Displays nothing Displays the digit ? 1–9 . \ Displays 0. Displays a single space. Displays the token. Separates the integer part from the fractional one. Before a decimal separator , If a digit is not supplied Separates groups of thousands. As the last token Displays the number after division by 1000. Separates the numerator and the denominator of a fraction. 56 Separates the integer and the fractional parts of a fraction. % Multiplies the given value by 100 and displays it with a percentage symbol. E+ Displays the number in scientific notation. E- Displays the number in scientific notation without a plus sign. [$symbol-HexCode] Displays the specified currency sign of the specified country. [$symbol] Displays the specified currency sign. Notes • Entering only a decimal separator is enough to display the whole integer part of a number in decimal notation. • If the specified format defines less decimal places than the supplied number actually has, the resulted number is displayed rounded. • A formatting rule cannot contain more than one exponent token. • A formatting rule cannot contain more than one currency token. 57 Examples A 1 B C Input value Format D Formatted value 2 1234.567 #.#### 1234.567 3 1234.567 00,000.0000 4 1234.567 ????.???? 5 1234.567 .##, 1.23 6 22.567 #/# 8642/7 7 22.567 # #/# 01,234.5670 1234.57 1234 4/7 8 Date and time Custom date/time formats are composed of special tokens, which cannot be used along with number tokens. The separators that were described above only visually separate date/time tokens and do not perform any additional operations. Rules with these tokens align formatted values to the right. Token Behavior Example / Separates the day, month, and year parts of a date. Can be replaced by a dot (.), a hyphen (-), and other separators. 1/1/1900 d Displays the day part with only significant figures. dd Displays the day part with a leading zero. ddd Displays the day of the week in short form. dddd Displays the day of the week in full form. m mm Displays the month part with only significant figures. Displays the month part with a leading zero. 58 1 01 Mon Monday 1 01 mmm mmmm Displays the name of the month in short form. Jan Displays the the full name of the month. January mmmmm Displays the first letter of the month’s name. yy J Displays only 2 last digits of the year part. 00 yyyy Displays the year part of the date using 4 digits. 1900 ww Displays the week of the date. 1 r Displays the era in short form. AD rr Displays the era in long form. q Displays the quarter of the date in short form. qq Displays the quarter of the date in long form. Anno Domini Q1 1st quarter Examples A 1 B C Input value Format D Formatted value 2 1234.567 m/d/yyyy 5/18/1903 3 1234.567 q yyyy Q2 1903 4 1234.567 yyyy r 1903 AD 5 1234.567 mmm d May 18 6 All dates can be extended with time tokens, which format decimal parts of numbers into hours, minutes, and seconds. 59 Token : Behavior Separates hours, minutes, and seconds. Can be replaced with other separators. Example 12:12 Separates date from time. Can be replaced with other 1/1/92 12:12 separators. h Displays hours with only significant figures. hh Displays hours with a leading zero. m Displays minutes with only significant figures. Must follow after hours or precede seconds; otherwise displays months. 1 mm Displays minutes with a leading zero. Must follow after hours or precede seconds; otherwise displays months. 01 s Displays seconds with only significant figures. s.0 s.00 s.000 Displays seconds with milliseconds and only significant figures. ss ss.0 ss.00 ss.000 Displays seconds with a leading zero. Displays seconds with milliseconds and a leading zero. 1 01 1 1.1 1.12 1.123 01 01.1 01.12 01.123 am/pm Displays time in 12-hour clock format. 1 AM a/p [h] Displays the number of hours that passed since the editor’s base date (12/30/1899). With only significant 60 figures. 1 [hh] Displays the number of hours that passed since the editor’s base date (12/30/1899). With a leading zero. 01 [m] Displays the number of minutes that passed since the editor’s base date (12/30/1899). With only significant figures. 1 [mm] Displays the number of minutes that passed since the editor’s base date (12/30/1899). With a leading zero. 01 Displays the number of seconds that passed since the editor’s base date (12/30/1899). With only significant figures. 1 [s.0] Displays the number of seconds that passed since [s.00] the editor’s base date (12/30/1899). With [s.000] milliseconds and only significant figures. 1.1 1.12 1.123 [ss.0] Displays the number of seconds that passed since [ss.00] the editor’s base date (12/30/1899). With [ss.000] milliseconds and a leading zero. 01.1 01.12 01.123 [s] Notes One formatting rule cannot contain more than one [h], [m], or [s] token. 61 Examples A 1 B C Input value Format D Formatted value 2 1234.567 m/d/yyyy h:m:s 5/18/1903 13:36:28 3 1234.567 h:m am/pm 4 1234.567 [h] 1:36 PM 29629 5 Additional tokens Token *symbol _ "any text" @ general [Color 1–56] [Cyan] [Green] [Black] [Blue] [Magenta] [Red] [White] [Yellow] Behavior Aligns the next character to the right and fills the created space with the supplied symbol. Makes the next character invisible. Displays the supplied text at the given position. Displays the value as text. Displays the value without changes. Displays the value in the specified color. Notes • TEXT ignores the following tokens: *symbol, _, and all color tokens. 62 • The at sign (@) cannot be used with number and date/time tokens. • One formatting rule cannot contain more than one color token. Examples A 1 B C Input value Format D Formatted value 2 123 $*# $ 123 3 123 #_$ 4 123 "Week" ww "of year" yyyy Week 18 of year 1900 5 123 mmmm d"nd", yyyy 6 123 [cyan]@@ 123$ May 2nd, 1900 123123 7 Formats with multiple rules A custom format can consist of several sections, each with its own formatting rule and required condition. Such sections are separated from each other with semicolons (;). For example: ##.00;(##.00);???;@@ By default, the first four sections match the following conditions: • Section 1: If the formatted value is greater than zero (0). • Section 2: If the formatted value is less than zero (0). • Section 3: If the formatted value is equal to zero (0). • Section 4: If the formatted value is text. Custom conditions are entered inside square brackets, at the beginning of each section. One section cannot contain more than one logical expression. 63 Examples A 1 B C Input value Format 2 Formatted value Default sections 3 1 #.0;(#.0);-;@ 1.0 4 -1 #.0;(#.0);0;@ (1.0) 5 6 0 #.0;(#.0);"zero";@ text1 zero #.0;(#.0);0;@@ text1text1 7 8 Custom sections 9 3 [>2]#.#;(#.#);"zero";@@ 3. 10 1 [>2]#.#;(#.#);"zero";@@ zero 11 1 [=1]0.0 "kilometer";0.0 "kilometers" 1.0 kilometer 12 10 [=1]0.0 "kilometer";0.0 "kilometers" 10.0 kilometers 13 64 D Autodetect mechanism Everything you type into a cell is actually a text string. The autodetect mechanism analyzes such strings and saves them as values of different types: numbers, errors and so on. When the mechanism detects a number, it also tries to detect what formatting you want to apply to the number. The detectable formats are: • General • Number • Fraction • Percentage • Currency • Scientific • Time • Date • Date and time Some of these formats have multiple variations. For example, a number in Currency can be presented with different currency signs and abbreviations ($, USD, and so on). When you select a format manually, you always apply its default variation. When a format is selected automatically, it takes the variation that resembles the entered string the most. The general rules of autodetect are the following: • It ignores letter case. For example, you can enter the Euler’s symbol both in lower and upper case. • When a format is detected, it overrides the previous one. Only General does not override other formats. • All positive numbers, except time and dates, are displayed negative if you enclose them in parentheses. • A fractional part is displayed only if it was entered. • Multiple unary signs before numbers, except time and dates, are converted to a single one according to arithmetic rules. If the resulted sign is a plus, it is omitted. 65 • When you enter time or dates, consider the following limits: Component Range of digits Range of values Hours 1-2 0–23 Minutes 1-2 0–59 Seconds 1-2 0–59 Milliseconds 1-3 0–999 Day 1-2 1–28 (29,30,31) Month 1-2 1–12 Year 1, 2, or 4 0001–9999 General This format is applied when you enter integers, decimal numbers, and when the mechanism does not detect a number. If you apply it manually, you get the same result. Entered Detected 12 1.234 1.234.56 Applied manually 12 12 1.234 1.234 1.234.56 1.234.56 Number This format is applied when you enter numbers with thousand separators. If you apply it manually, your numbers are displayed without thousand separators and with two digits after the decimal point (even if they are zeros). Entered 1,234 Detected Applied manually 1,234 1234.00 Notes • You must enter at least one digit before a thousand separator and at least three digits after it. Otherwise, the mechanism detects text and applies General. Entered 12,3 Detected Applied manually 12,3 12,3 • You do not need to separate all groups of thousands. If you enter one separator at the right position, the editor places the rest automatically. 66 Entered Detected Applied manually 1,23456789.012 123,456,789.01 123456789.01 123456,789.012 123,456,789.01 123456789.01 Percentage This format is applied when you enter integers or decimal numbers with a percentage sign (%), which can be placed either before or after the numeric part of your string. If you apply this format manually, the numeric part is displayed with two digits after the decimal point (even if they are zeros). Entered Detected Applied manually 1% 1% 1.00% %1 1% 1.00% Currency This format is applied when you enter integers or decimal numbers with a currency sign or abbreviation either before or after the numeric part. When you apply this format manually, the editors selects the default currency sign or abbreviation of your system. In the following example, the default currency sign of the system is the dollar sign ($). Entered 25$ Detected Applied manually $25 $25 USD 23 USD 23 $23 25,100C C25,100 $25,100 Fraction This format is applied when you enter numbers that are composed of three separated parts: integer, numerator, and denominator. The integer part must be separated from the fractional one with any spacing, and the numerator must be separated from the denominator with a slash (/). When you apply this format manually, you get the same result. Entered 1 1/2 Detected Applied manually 1 1/2 1 1/2 Autodetect reduces all fractions to lowest terms. If the result is an integer, the mechanism still sets Fraction. 67 Entered Detected Applied manually 1 2/4 1 2/4 1 2/4 1 2/2 2 2 Scientific This format is applied when you enter numbers in scientific E-notation. When you apply this format manually, you get the same result. Entered Detected Applied manually 2.12E+14 2.12E+14 2.12E+14 3.23E-28 3.23E-28 3.23E-28 You can omit the plus sign if you want to enter a positive exponent. Entered 2.12E14 Detected Applied manually 2.12E+14 2.12E+14 Time This format is applied when you enter time in 24- or 12-hour clock. When you apply this format manually, time is always displayed with seconds. Entered Detected Applied manually 13:25:00 1:25:00 PM 1:25:00 PM 9:25 am 9:25 AM 9:25:00 AM Notes • You can enter time with precision up to milliseconds. To separate them from seconds you must use the decimal point. Milliseconds affect calculations but can be displayed only with the help of custom formatting or TEXT. Entered Detected Applied manually 13:45:46.123 13:45:46 PM 13:45:46 PM 13:45:46.999 13:45:47 PM 13:45:47 PM • The autodetect mechanism allows you to omit different time components (hours, seconds, and so on). Omitted hours are treated as 12 AM (unless you specified PM). Omitted minutes, seconds, and miliseconds are treated as zeros. 68 Entered Detected Applied manually 19:30 7:30 PM 7:30:00 PM 1 pm 1:00 PM 1:00:00 PM 12:30:30 PM 12:30:30 PM 12:45 AM 12:45:00 AM :30:30 :45: Date This format has multiple variations. You can change the number of displayed components, present the month part with numerals or letters, use different separators, and so on. Entered Detected Applied manually 11/23/2009 11/23/2009 11/23/2009 11-23-2009 11/23/2009 11/23/2009 Nov 23, 2009 11/23/2009 November 23 23-Nov 11/23/2019 11/2009 Nov-09 11/1/2009 23 Nov 2009 Notes • If you enter year in short form, the editor adds 2000 years to the given number. For example, 11/15/19 is detected as 11/15/2019, and 10/30/1 is detected as 10/30/2001. • When you enter dates with month names or abbreviations, you can separate the components with any spacing or not use a separator at all. • You can omit day or year in a date. When you omit year, the editor sets the current year. When you omit day, the editors sets the first day of the given month. Date and time This format is applied when you enter date and time in a single string (in the given or opposite order) and separate them from each other with any spacing. If you apply this format manually, you get the same result. Entered 7/23/2018 12:45 pm Detected Applied manually 7/23/2018 12:45 pm 7/23/2018 12:45 pm 26 April 19:30:30 4/26/2019 7:30 PM 4/26/2019 7:30 PM 16:45 Aug 1998 8/1/1998 4:45 PM 8/1/1998 4:45 PM 69 Autodetect in formulas When you enter formulas, the editor formats their results. It analyzes the given operands and applies the first detected format. If it cannot detect any, it applies General. For example, formula in the B2 cell is =10%+1 1/2. The editor detects two numbers in different formats (Percentage and Fraction) and applies the first format (Percentage) to the result. A B C 1 2 160% 3 In the formula above, the editor detected operands in a plain string. In most cases, it cannot do so because formatting patterns become ambiguous inside formulas. If you want to enter a formatted number, you must enclose it in double quotation marks to indicate that the marked out string is a single operand. For example: ="12/1/12"+1 A B C D 1 2 12/2/2012 3 The editor can also detect formats through references. For example: A 1 B C D 12% 1/11/1900 2 1212% =A1+B1 3 4 Note If a string is the only element of your formula, the result is a string in General. Autodetect in functions Most functions ignore automatically detected formats and return either General or their predefined formats. For example, PRODUCT always returns General and DATE always 70 returns Date. =PRODUCT(1 1/2,"1$"). A B 1 C 1.5 2 =DATE(2010,1 1/2,100%). A B 1 C 1/1/2010 2 Some functions keep the automatically detected format. For example: =MAX(100%,2,3 1/2). A 1 B C 350% 2 Note Functions always ignore formats that are supplied with references. 71 Chapter 4 Localization 72 Introduction Localization is a mechanism that adapts a product to user needs depending on language and region preferences. Translation is a significant part of this mechanism, but on its own, it does not guarantee consistent functionality. Identifying the right language– region combination and adapting such aspects as measurement systems and formatting rules is no less important. How language and region affect localization Localization of different elements depends either on language or region. Language determines translation of tooltips, error messages, names of months, and other text components. Region sets systems of measurement, formatting patterns, and so on. In some cases, both language and region affect the localization of a single component. For example, the word color is spelled colour in British English, therefore to display this component correctly, both language and region have to be considered. At any rate, localization of multiple components cannot rely either on language or region. For this reason, localization in our editor relies on locale. What is locale A locale is a combination of a language and a region. An example of a locale is English—Australia. Our editor gets the user locale directly from the user’s system. If the received combination is not supported, application replaces it with the closest supported one. If the replacement is impossible, the application sets the default locale, which is English— United States. System settings Most operating systems allow users to set not only language and region but also other related preferences, such as decimal and thousand separators. Our editor pulls these preferences from the system and use them in localization. However, if they are inconsistent (in other words, they break the editor’s functionality) the application adapts them using its own localized resources. 73 Cross-locale documents Our editor localizes every document according to the current user locale regardless of any changes made and saved by a user with another locale. This behavior also applies to Collaboration, which provides each of the collaborators (simultaneous users) with a localized document. 74 Locale identification Localization allows our editor to work with not supported locales. This section describes how our editor identifies locales and handles the unknown ones. To receive a system locale, our editor sends a request to UI (user interface), which pulls the required data directly from your system. The exception is the web application, in which the language must be selected manually by you. The following diagram shows the operations performed by the editor after receiving a locale: System locale Is the locale supported? no Is the language valid? no yes Is the region valid? yes Set the locale by language Set the locale by region yes Save the locale The editor currently supports 6 locales: • English–United States • English–Canada • English–United Kingdom • English–Australia • English–New Zealand • Russian–Russia 75 no Set EnglishUnited States When the editor receives one of the listed locales, it saves the combination and passes it to the UI. Otherwise, the editor tries to replace the received locale with the closest supported one. Identification by language Language has more significant impact on localization elements than region, so the editor prioritizes identification by language. This operation is possible only with valid languages. A language is considered valid in the following cases: • It is supported: English and Russian. • It can be replaced with Russian without loss to functionality. For example, Armenian (for the full list, see subsection 4.2). Is the language supported yes Combine with the corresponding region no Is the language replaceable? no Identification by region yes Replace the language Notes • If the language is supported, the editor saves it and combines it with its default region. As a result, not supported locales that contain English or Russian are converted to English–United States and Russian–Russia respectively. • If the language can be replaced by Russian, the editor sets Russian–Russia as the locale. Replaceable languages The following languages are replaced with Russian: • Armenian • Belorussian • Kazakh 76 • Kyrgyz • Romanian • Tajiki • Turkmen • Uzbek • Ukrainian • Bashkir • Tatar Identification by region If the editor receives an invalid language, it tries to set the locale by region. For a successful identification, the editor needs a valid region. A region is considered valid in the following cases: 1. It is supported. For example, United Kingdom. 2. It can be replaced with Russia without loss to functionality. For example, Armenia. (for the full list, see Replaceable regions). Is the region supported yes Combine with the corresponding language no Is the region replaceable? no Set the default locale yes Replace the region Notes • If the region is supported, the editor saves it and combines it with the corresponding supported language. As a result, such regions as French–Australia are converted into English–Australia. 77 • In the region can be replaced by Russia, the editor sets Russian–Russia as the locale. • If the region is invalid, the editor sets the default locale, which is English–United States. Replaceable regions The following regions are replaced with Russia: • Armenia • Belarus • Kazakhstan • Kyrgyzstan • Moldova • Tajikistan • Turkmenistan • Uzbekistan • Ukraine Partially supported languages Some languages (for example, Bashkir) are partially supported in our editor. They affect only UI elements of the editor (toolbar, drop-down menus, and so on). The rest of the application is localized according to general rules. 78 System UI Identification mechanism locale Is the system language supported? no Apply the received locale yes Apply the system language to UI Apply the received locale to other elements Examples 1. The system locale is English–Canada. This combination is supported, so the editor applies it. 2. The system locale is Russian–Canada. This combination is not supported, but the language is valid. The editor applies Russian–Russia because it is the default locale for Russian. 3. The system locale is Bashkir–Canada. This combination is not supported, but the language can be replaced. The editor saves Russian–Russia because Bashkir is replaced with Russian, and the default region for this language is Russia. However, the UI elements are localized to Bashkir. 4. The system locale is French–Canada. This combination is not supported, the language is invalid, but the region is supported. The editor applies English–Canada because it is the default locale for Canada. 79 5. The system locale is French–Kyrgyzstan. This combination is not supported, the language is invalid, but the region can be replaced. The editor applies Russian–Russia because Kyrgyzstan is replaced by Russia, and Russian is the default language for Russia. 6. The system locale is French–Switzerland. This combination is not supported, and both language and region are invalid. The editor sets the default locale, which is English–United States. 80 Chapter 5 Pivot tables 81 Pivot table overview A pivot table analyzes your data and creates a report with criteria. When you have large data sets, creating and editing reports with a pivot table is much faster and easier than working with formulas. This article introduces the most commonly used pivot table features. Creating and editing a report Data (below, only a fragment is displayed): A B C D Country SalesRep Product E G 1 Date 2 2009-06-07 UK Ezra SuperX Core $75.00 29 $2,175.00 3 2009-08-11 Spain Hatter SuperX Basic $50.00 44 $2,200.00 4 2009-10-15 Italy Donovan SuperX Basic $50.00 38 $1,900.00 5 2009-12-19 Spain Struksen SuperX Deluxe $100.00 12 $1,200.00 6 2010-02-22 US Hatter SuperX Core 34 $2,550.00 A report created with a pivot table: A 1 SalesRep 2 Dunn B ³ Product C ³ Sum of Sales 3 SuperX Basic 3100 4 SuperX Deluxe 1500 5 Dunn Total 6 Ezra 4600 7 SuperX Core 2175 8 SuperX Deluxe 2700 9 Ezra Total 4875 10 Hatter 11 SuperX Basic 2200 12 SuperX Core 2550 13 Hatter Total 4750 14 Stoke 15 SuperX Basic 1650 16 SuperX Deluxe 1200 17 Stoke Total 2850 18 Grand Total 17075 82 Prbice F $75.00 Units Sales The same report is edited to use different criteria and data arrangement: A B C Country D E F Italy Spain US UK 1900 2700 1 Sum of Sales 2 SalesRep 3 Dunn 4 Ezra 2700 2175 5 Hatter 2200 6 Stoke 1650 1200 7 Grand Total 1650 1900 6100 2175 5250 ³ G ³ China Grand Total 4600 4875 2550 4750 2850 17075 Tip See Create and edit pivot tables to learn how to prepare data for a pivot table and how to edit a pivot table report. Filtration To hide unnecessary data in your report, use filters: A 1 B SalesRep Dunn X 2 3 Years 4 2009 1900 5 Grand Total 1900 X Sum of Sales The filters are set to display sales in 2009 and for a sales representative named Dunn. Tip See Filtering data in a pivot table to learn how to use filters in a pivot table. Changing the aggregate function By default, a pivot table uses SUM as the aggregate function for numeric values (or COUNT for text), but you can use other functions as well: 83 A B 1 Country Average of Sales 2 China 1650 3 Italy 1900 4 Spain 2033 5 UK 2175 6 US 1750 7 Grand Total 1897 ³ In this report, AVERAGE is used to summarize the sales. Tip See Aggregate functions for the full list of available functions. Load only features The following features can not be enabled or edited in the editor, but you can load documents that already have them enabled: Sorting In the following report, sales representative are sorted from Z to A: A B 1 SalesRep 2 Stoke 2850 3 Hatter 4750 4 Ezra 4875 5 Dunn 4600 6 Grand Total ³ Sum of Sales 17075 Note Any changes to a pivot table resets sorting to the ascending order: • from A to Z for text; • from Smallest to Largest for numbers; • from Oldest to Newest for dates. 84 Grouping Analyze smaller subsets of your data by loading pivot tables with groups. In the following report, Italy, Spain, and UK are combined into a custom group named Europe: A 1 Country 2 China 3 B ³ Sum of Sales China 1650 4 China Total 5 Europe 6 Italy 1900 7 Spain 6100 8 UK 2175 9 1650 Europe Total 10175 10 US 11 US 5250 12 US Total 5250 13 Grand Total 17075 Additional calculations Load pivot tables with additional calculations to enhance data comparison: A B 1 Country 2 China 3 Italy 11.13% 4 Spain 35.72% 5 UK 12.74% 6 US 30.75% 7 Grand Total ³ Sum of Sales 9.66% 100% The pivot table performs additional calculations to display all aggregates as percentages of the Grand Total. 85 Create and edit pivot tables Related topics: Pivot grouping, Aggregate functions, Filtering data in a pivot table. A report created with a pivot table differs from regular ranges with values and formulas. This article describes the main stages of working with such a report. Preparing your data A pivot table can only summarize data of specific structure. You need a cell range with columns of values. Each column must start with a heading: A B Name C 1 Date 2 2009-06-07 C. Dickens 3 2009-08-11 C. Bukowski $650.00 D Sales $750.00 Inserting a pivot table To start working with a pivot table, insert it into your workbook using the Insert menu or the Insert tab. Both actions open a window, in which you have to specify the location of your data source and your future pivot table, for example: A1:F10 If you work with multiple worksheets, specify the address with the sheet name: 'Sheet1'!A1:F10 If your range has a name, you can use it instead of the address: MyDataSource1 Some named ranges work only on the sheets they were created on. To specify such a range as your data source, add the sheet name: 'Sheet1'!MyNamedRange Tip While you are in the Create Pivot Table dialog box, you can click on any cell of your named range to automatically select it as the data source. 86 If you frequently work with imported documents, you may be familiar with ranges that have banded rows, applied sorting and filtering, and dynamic size: Note Microsoft Excel users may know such ranges as Excel tables. A 1 Date B ³ 2 3/1/21 3 Time C ³ Title D ³ 9:12 Women Edition E ³ Price/Unit ³ paperback $8.95 3/2/21 11.25 Ham on Rye hadrcover $13.95 4 3/2/21 12:40 Ham on Rye e-book $11.99 5 3/2/21 13:45 Post Office paperback $8.95 You can refer to such ranges by their names: Table1 Also, data in such ranges can be accessed with structured references, which are references composed with column headers and special modifiers instead of letters and numbers. For example, two column names can be used to specify the data source for your pivot table: Table1[[Date]:[Edition]] A 1 Date B ³ 2 3/1/21 3 Time C ³ Title D ³ 9:12 Women Edition E ³ Price/Unit ³ paperback $8.95 3/2/21 11.25 Ham on Rye hadrcover $13.95 4 3/2/21 12:40 Ham on Rye e-book $11.99 5 3/2/21 13:45 Post Office paperback $8.95 The highlighted range is used as the data source. To specify the location of your future report, you need to specify a cell address: 'Sheet1'!G7 Or you can tell the editor to create a new worksheet for your pivot table by selecting the corresponding option in the dialog. 87 Tip When you place a pivot table on a worksheet that already has data, the created pivot table can overlap the existing data and result in an error message. To avoid this, insert pivot tables into new worksheets. You can change your data source at any time in the pivot table options. Editing For a pivot table, each column in your data source is a field. For example, the following table has seven fields (Date, Time, Title, Edition, Price/Unit, Units, and Total Price): A B C Time Title D E G 1 Date 2 3/1/21 paperback $8.95 8 $71.60 3 3/2/21 11.25 Ham on Rye hadrcover $13.95 3 $41.85 4 3/2/21 12:40 Ham on Rye e-book $11.99 1 $11.99 5 3/2/21 13:45 Post Office paperback $8.95 9 $80.55 6 3/2/21 14:50 Ham on Rye paperback $1.21 6 $7.26 7 3/2/21 16:40 Women hardcover $14.58 1 $14.58 8 3/3/21 9:00 Post Office e-book $13.99 1 $13.99 9 3/3/21 9:06 Ham on Rye paperback $7.15 30 $214.50 9:12 Women Edition F Price/Unit Units Total Price Note If your data source have multiple columns with identical headings, the pivot table uses numbers to distinguish fields from each other. For example, if you have two Date columns, for a pivot table, they will be Date and Date1. To fill your report with data, you need to add fields to the report and specify how they should be used by the pivot table: As Columns adds a field to create criteria that are placed as column headings: 88 A B C D 1 2 Title 3 Ham on Rye Post Office Women Grand Total ³ 4 You can add more fields to create subcriteria: A B 1 Title 2 Ham on Rye 3 e-book C D E ³ Ham on Rye Total Post Office hardcover paperback Tip You can also change the hierarchy of your headings. As Rows adds a field to create criteria that are placed as row headings: A B Title 1 2 Edition 3 e-book 4 hardcover 5 paperback 6 Grand Total ³ C D E ³ Ham on Rye Post Office Women Grand Total Subcriteria are also possible: A 1 Title 2 Ham on Rye 3 e-book 4 hardcover 5 paperback ³ 6 Ham on Rye Total 7 Post Office As Values adds a field as a data set for calculating an aggregate: 89 A B C D E 1 Sum of Units Title 2 Edition Ham on Rye Post Office Women Grand Total 3 e-book 4 ³ ³ 2 3 1 6 hardcover 11 2 2 15 5 paperback 44 11 9 66 6 Grand Total 59 16 12 87 You can also add another field to perform calculations on two sets of values: A 1 B Sum of Units Title C D ³ Ham on Rye 2 3 Edition 4 e-book 5 ³ Post Office Sum of Units Sum of Total Price Sum of Units 2 16.99 3 hardcover 11 165.69 2 6 paperback 46 293.26 11 7 Grand Total 59 475.94 16 By default, the calculations are performed with SUM for numbers and with COUNT for other values, but you can use other aggregate functions as well (see Aggregate functions for the full list). Tip You can even add the same field to Values multiple times. This is useful when you want to perform different calculations on one set of values. As Filter adds a field to create criteria that are placed above the report: A 1 B C Date 3/1/2021 X 3 Sum of Units Title ³ 4 Edition Women 5 paperback 8 8 6 Grand Total 8 8 2 X Grand Total 90 Note Filters are also created automatically for each set of headings or values. See Pivot table filters for more information. To rearrange data in your report you can • add more fields, • remove the existing ones, • respecify the fields that have already been added. Updating and deleting pivot tables Changes that you make in your data source, do not transfer automatically to your pivot table. To get them, you need to update your pivot table using the Update option. If you have multiple pivot tables, each of them must be updated separately. Tip When you open a document with a pivot table, the pivot table is not connected to its data source. To connect them, use the Update option or start editing your pivot table. A pivot table remembers the location of its data source as a range address in your workbook. If you enter data outside this range (unless its dynamic), your pivot table cannot detect it. To supply your pivot table with new data, change the address of your data source in the pivot table options. Tip Another way to supply your pivot table with more data is to insert new rows and columns into your data source. When you add data this way, data source change is not required. To analyze less data, delete unnecessary rows and columns from the range. To delete a pivot table, you must delete all its cells together because it is a single object. 91 Pivot grouping Grouping separates pivot table data into smaller subsets, which are easier to analyze. Note Currently, you cannot create groups yourself, but you can load documents that already have them. Editing is fully supported. Grouped text items This type of grouping usually highlights subtotals for locations, products, or sales representatives. Grouped rows: A B 1 Units Sold Product 2 City Blanket 3 West ³ C D E ³ Pillow Socks Grand Total 4 San Diego 368 368 5 San Jose 118 118 6 West Total 486 486 7 East 8 Boston 9 Tampa 2095 421 2516 741 2074 2815 10 East Total 2095 741 2495 5331 11 Grand Total 2095 1227 2495 5817 Grouped columns: A 1 B Units Sold C Product E Blanket Bedroom Total Socks Socks Total 3 City 4 Boston 5 San Diego 368 368 6 San Jose 118 118 7 Tampa 741 8 Grand Total 1227 ³ F ³ Bedroom 2 D Pillow Socks 2095 2095 2095 92 421 421 741 2074 2074 3322 2495 2495 For a pivot table, each level of grouping is an additional field. You can easily recognize such fields by their names because they are similar to fields with grouped items: for example, City2 and Product2. To remove a grouping level, remove the corresponding field from your report: A B 1 Units Sold Product 2 City Blanket ³ C D E ³ Pillow Socks Grand Total 3 San Diego 368 368 4 San Jose 118 118 5 Boston 6 Tampa 7 2095 Grand Total 2095 421 2516 741 2074 2815 1227 2495 5817 You can also remove the field with grouped items and leave just the groups: A B C D E 1 Units Sold Product 2 City Blanket 3 West 4 East 2095 741 2495 5331 5 Grand Total 2095 1227 2495 5817 ³ ³ Pillow Socks Grand Total 486 486 Grouped dates Dates can be grouped by years, quarters, months, days, hours, minutes, and seconds; with multiple levels of grouping enabled at once: A B 1 Date 2 2010 3 Q3 4 4 Q4 6 5 2011 6 Q1 10 7 Q2 7 8 Q3 4 9 Q4 6 ³ 10 Grand Total Units 37 93 Note Multiple levels of date grouping come with extra fields, which can be Years, Quarters, Months, Days, Hours, Minutes, and Seconds. Grouping can cover all dates or a certain period: A B 1 Date 2 <1/1/2011 10 3 Q1 10 4 Q2 7 5 Q3 4 6 Q4 6 7 Grand Total ³ Units 37 A grouping interval can be an arbitrary number of days: A B 1 Date 2 <10/31/2010 5 3 10/31/2010 - 11/27/2010 2 4 11/28/2010 - 12/25/2010 3 5 >1/1/2011 27 6 Grand Total 37 ³ Units Grouped numbers Grouping numbers is a great way to show frequency distribution in your report. Instead of having a very long list of values, you can get a compact summary. In the following table, numbers are grouped by 500: A 1 Orders 2 Units 3 100-599 4 600-1099 5 Grand Total B Product ³ C D E F ³ San Diego San Jose Tampa Boston Grand Total 1 1 5 8 7 21 5 5 6 16 10 13 13 37 94 Grouping can be specified with the starting and ending points: A B 1 Units 2 <500 3 500-599 1 4 600-700 6 5 700-799 1 6 800-899 5 7 900-999 4 8 Grand Total ³ Transactions 20 37 Once enabled, number grouping can detect changes in your data source and adapt accordingly: Note Remember to update your pivot table after any changes in the data source. A B 1 Units 2 <500 3 500-599 1 4 600-700 6 5 700-799 1 6 800-899 5 7 900-999 4 8 1500-1600 1 9 Grand Total ³ Transactions 20 37 As a result of changes in the data source, additional group is created (1500-1600). 95 Filtering data in a pivot table Related topics: Pivot grouping, Create and edit pivot tables. Filtration allows you hide data that do not satisfy specific conditions. This article describes how to enable it. Applying filters to Rows and Columns fields When you create a pivot table with at least one field of criteria, you already have a filter. In the following example, the report has a filter by Date: A B 1 Date 2 01/01/2020 2248.72 3 01/02/2020 2366.46 4 01/03/2020 2684.92 5 01/04/2020 2402.48 6 01/05/2020 3066.87 7 Grand Total 12769.45 ³ Sales The filter is enabled to show sales for January 1, 2020: A B 1 Date 2 01/01/2020 3 Grand Total 2248.72 X Sales 2248.72 You can set multiple conditions for a filter: A B Sales 1 Date 2 01/01/2020 2248.72 2 01/02/2020 2366.46 3 Grand Total 4615.18 X Note Currently, filters can only search for an exact match (in other words, if a value is equal to another value). 96 To narrow down your results even more, you can enable filters for multiple fields: A B C 1 Sum of Sales Product 2 Date Lion 3 01/01/2020 458.92 458.92 4 01/02/2020 480.2 480.2 5 Grand Total 939.12 939.12 X X Grand Total This filter shows only Lion sales for January 1 and January 2. Note A pivot table remembers the state of your filter even after you remove the field with the filter. If you want to see all your data again, clear the filter manually. Adding fields as Filters To apply additional criteria, you can add fields as filters. For example, the Discount field: A B C 1 2 Discount 3 Sum of Sales Product 4 Date 5 01/01/2020 209.52 209.52 6 01/02/2020 725.76 725.76 7 01/03/2020 768.42 768.42 8 01/04/2020 823.5 823.5 9 01/05/2020 1213.38 1213.38 2655.43 2578.24 10 Grand Total 10% ³ X ³ Snickers Grand Total When you add several filter fields, your pivot table shows results that satisfy both conditions at once: 97 A B C 1 2 3 Discount City 10% Swansea 4 Sum of Sales Product 5 Date 6 01/03/2020 121.5 121.5 6 01/04/2020 557.28 557.28 7 01/03/2020 858.06 858.06 8 Grand Total 1536.84 1536.84 ³ X X ³ Snickers Grand Total Note • Filtration via charts can not be enabled. However, if you load a pivot table with this type of filtering enabled in other editors, the filtering options are saved. • Filtration via slicers and timelines is not supported. 98 Aggregate functions The full list of functions that can be used to summarize data in a pivot table: Name Sum Description The sum of all numeric values. The default function for numbers. Count The quantity of values. The default function for non-numeric values. Count Numbers The quantity of numeric values. Average The average of numeric values. Max The maximum value. Min The minimum value. Product The product of numeric values. StdDev An estimated standard deviation of a population, where the values are a subset of the entire population. StdDevP The standard deviation of a population, where the values are the entire population. Var An estimated variance of a population, where the values are a subset of the entire population. VarP The variance of a population, where the values are the entire population. 99 Additional calculations The full list of additional calculations that can be loaded with a pivot table: Name % of Shows the value as percentage of an item in a field. Difference from Shows the value as difference from an item in a field. % of difference from Shows the value as percentage difference from an item in a field. Running total in Shows the value as a running total in a field. % of row total Shows the value as percentage of row total. % of column total Shows the value as percentage of column total. % of grand total Shows the value as percentage of grand total. Index Calculates the relative weight of the value based on totals: (Value) * (Grand Total Of Grand Totals) / (Grand Row Total) * (Grand Column Total). 100 Pivot table options Related topics: Pivot grouping, Create and edit pivot tables. The appearance of your pivot table is largely affected by its options. Currently, you cannot change them, but pivot tables that were created in other editors can be loaded with modified options. Data source This setting allows you to change your data source at any time and does not affect any other settings. Note Changing your data source automatically updates your pivot table. Show totals This setting enables and disables grand totals for rows and columns: • For columns. A B C D 1 2 ³ Sum of Units Title ³ Ham on Rye Post Office Women Edition 3 e-book 4 2 3 1 hardcover 11 2 2 5 paperback 44 11 9 6 Grand Total 59 16 12 • For rows. A B C D E 1 2 ³ Sum of Units Title ³ Ham on Rye Post Office Women Grand Total Edition 3 e-book 4 5 2 3 1 6 hardcover 11 2 2 15 paperback 44 11 9 66 6 By default, totals are displayed for both rows and columns: 101 A B C D E 1 2 ³ Sum of Units Title ³ Ham on Rye Post Office Women Grand Total Edition 3 e-book 4 2 3 1 6 hardcover 11 2 2 15 5 paperback 44 11 9 66 6 Grand Total 59 16 12 87 Table layout This setting changes the layout form of your pivot table: • Compact displays all row headings in the same column and uses indentation to distinguish levels. This is the default pivot table layout. A 1 Edition 2 Ham on Rye B ³ Sum of Units 3 e-book 2 4 hardcover 11 5 paperback 46 6 Ham on Rye Total 59 7 Post Office 16 • Tabular displays each level of headings in a separate column. A 1 Title 2 Ham on Rye B ³ Edition C ³ Sum of Units e-book 2 3 hardcover 11 4 paperback 46 5 Ham on Rye Total 6 Post Office 59 e-book 3 • Outline is similar to Tabular but skips one row before starting the next level of headings. 102 A B 1 Title 2 Ham on Rye ³ C Edition ³ Sum of Units 3 e-book 4 hardcover 11 5 paperback 46 6 Ham on Rye Total 7 Post Office 8 2 59 e-book 3 Captions This section of options controls the appearance of empty values, errors, and various other captions in your pivot table. For example, below all empty values are replaced with 0, and captions for rows and columns are changed: A B Sum of Units Transaction Date 1 2 ³ C Book Title Ham on Rye D E ³ Post Office Women Grand Total 3 03/01/2021 0 0 8 8 4 03/02/2021 10 9 1 20 5 03/03/2021 32 3 0 35 By default, captions are displayed without changes. Arrange filters The section controls the arrangement of fields that are added as filters: • Down, then to the right displays filters from top to bottom before starting a new column (works in conjunction with Filter fields per column). By default, this option is enabled. • Filter fields per column sets how many filters you want to display before starting a new column when Down, then to the right is enabled. A B C 1 Date (All Items) ³ 2 Time (All Items) ³ 3 Price/Unit (All Items) ³ D Title 4 103 E (All Items) ³ • To the right, then down displays filters from left to right before starting a new row (works in conjunction with Filter fields per row). • Filter fields per row sets how many filters you want to display before starting a new row when To the right, then down is enabled. A B C D E 1 Date (All Items) ³ Time (All Items) ³ 2 Price/Unit (All Items) ³ Title (All Items) ³ 3 Display value fields When you add more than one field to Values, the constructor creates an additional field with headings to distinguish results. This section controls the arrangement of these headings: • As columns displays them as column headings. By default, this setting is enabled. • As rows displays them as row headings. 104 Number formatting in pivot tables Related topics: Pivot table overview, Cell number formatting, Localization. Number formatting in pivot tables is defined in two ways: automatically based on your data source and manually through field settings. Automatic formatting based on your data source When you create a pivot table, it retains formatting from the data source for fields that are added as Rows, Columns, and Filters: A 1 B C D E F Data Source 2 3 Date Product Price per unit Quantity Discount Sales 4 01/01/2020 Bounty $0.65 374 25.00% $182.33 5 01/01/2020 Lion $0.40 349 30.00% A 1 B C D E $97.72 F Pivot Table 2 3 Sum of Sales 4 Date 5 01/01/2020 Discount ³ ³ 10.00% 20.00% 25.00% 30.00% Grand Total 209.52 1193.20 387.08 458.92 2248.72 Note Fields in the Values area always use the General format no matter how they are formatted in the data source. If your pivot table does not retain the formatting as you intended, make sure that you have only one format per column in your data source. Note Another reason why it is important to keep your data source formatting consistent is that equivalent values in different formats are treated by the editor as equal. For example, if a field has 200% and 2$, and you add it as a Rows, these two items are detected as one (number 2 in the General format). 105 The following examples demonstrate how a pivot table works with inconsistent formatting. Multiple formats in a data source column result in the General format (except for dates): A 1 B C D E F Data Source 2 3 Date Product Price per unit Quantity Discount Sales 4 01/01/2020 Bounty $0.65 374 5 01/01/2020 Lion $0.40 349 A 1 B C D 0.25 $182.33 30.00% E $97.72 F Pivot Table 2 3 Sum of Sales 4 Date 5 01/01/2020 Discount ³ ³ 0.1 0.2 0.25 0.3 Grand Total 209.52 1193.20 387.08 458.92 2248.72 Multiple variations of one format in a data source column result in the first detected format in the column: A 1 B C D E F Data Source 2 3 Date Product Price per unit Quantity Discount Sales 4 01/01/2020 Bounty $0.65 374 5 01/01/2020 Lion $0.40 349 A 1 B 25% $182.33 30.00% C D E 10% 20% 25% 30% 209.52 1193.20 387.08 458.92 $97.72 F Pivot Table 2 3 Sum of Sales 4 Date 5 01/01/2020 Discount ³ ³ 106 Grand Total 2248.72 Note • Dates are always formatted as your system’s short date with leading zeros (for example, 01/01/2020). • Time is always formatted according to your system regional preferences. • Mixing currency signs and currency codes result in the General format even if they correspond to one currency. Number formatting per field Pivot tables that were created in other editors can have individual number formatting per field: A B 1 Product 2 Bounty $2,655.43 3 Lion $2,578.24 4 Mars $3,795.20 5 Snickers $3,740.58 6 Grand Total ³ Sum of Sales $12,769.45 This type of formatting resets to the automatic one after editing or updating a pivot table. 107 Part II Description of functions 108 Chapter 6 Mathematical functions 109 ABS Returns the absolute value of a number. The result of calculation is always a positive number. Syntax =ABS(value) value — a number which absolute value is to be returned. Notes • If value contains or refers to non-numeric values except logical expressions, ABS returns the #VALUE! error. • If value takes an empty value or refers to an empty cell, ABS returns 0. • ABS supports numbers presented as strings, e.g. "12". The resulted value is recognized as a number. • ABS evaluates the TRUE logical value to 1, and FALSE – to 0. Examples A B 1 Data Result 2 -18 18 3 5 5 4 value 5 TRUE 6 C D E #VALUE! 1 7 7 1. Formula entered in the B2 cell is =ABS(A2). As a result, the function returns the absolute value of -18, that is equal to 18. 2. Formula entered in the B3 cell is =ABS(A3). As a result, the function returns the absolute value of 5, that is equal to 5. 110 3. Formula entered in the B4 cell is =ABS(A4). As a result, the function returns the #VALUE! error as the A4 cell contains a non-numeric value. 4. Formula entered in the B5 cell is =ABS(A5). As a result, the function returns the absolute value of the TRUE logical value, that is equal to 1 (as the TRUE logical value is evaluated to 1). 5. Formula entered in the B6 cell is =ABS("-7"). As a result, the function returns the absolute value of -7 ("-7" is casted to -7), that is equal to 7. 111 ACOS Calculates the arccosine, that is the inverse cosine of a given number, and returns an angle expressed in radians. Syntax =ACOS(value) value — a number for which the arccosine is to be calculated. It must be between -1 and 1, inclusive. Notes • If value is beyond the limit values (from -1 to 1), the #NUM! error is displayed. • ACOS supports numbers presented as strings, e.g. "1". The resulted value is recognized as a number. • If the argument is a cell reference with an empty value, ACOS evaluates it to 0 (zero). • If value is expressed in degrees, use the RADIANS function to convert the value to radians. Examples 1 A B C Data Result 2 1.369438406 3 1.019726744 4 2.434109442 5 0.66 0.849977566 6 #NUM! 7 1.570796327 D E 8 1. Formula entered in the B2 cell is =ACOS(0.2). As a result, the function returns the arccosine of 0.2 expressed in radians. 112 2. Formula entered in the B3 cell is =ACOS(RADIANS(30)). As a result, the function coverts 30 degrees to radians, that is 0.523598776, and returns the arccosine of the output value. 3. Formula entered in the B4 cell is =ACOS("-0.76"). As a result, the function returns the arccosine of -0.76 ("-0.76" is cased to -0.76). The output value is expressed in radians. 4. Formula entered in the B5 cell is =ACOS(A5). As a result, the function returns the arccosine of the value in cell A5. The output value is expressed in radians. 5. Formula entered in the B6 cell is =ACOS(6). As a result, the function returns the #NUM! error as the supplied number is beyond the limit values. 6. Formula entered in the B7 cell is =ACOS(A7). As a result, the function returns the arccosine of 0 as A7 is a reference to an empty cell. 113 ACOSH Calculates the inverse hyperbolic cosine for a number. Syntax =ACOSH(value) value — a number for which the inverse hyperbolic cosine is to be calculated. It must be a real number greater than or equal to 1. Notes • If value is less than 1, the #NUM! error is displayed. • Empty values considered in the calculation are casted to 0. Examples 1 A B C Data Result 2 2 1.316957897 3 1.9248473 4 D E #NUM! 5 1. Formula entered in the B2 cell is =ACOSH(A2). As a result, the function returns the inverse hyperbolic cosine of 2, that is equal to 1.316957897. 2. Formula entered in the B3 cell is =ACOSH(3.5). As a result, the function returns the inverse hyperbolic cosine of 3.5, that is equal to 1.9248473. 3. Formula entered in the B4 cell is =ACOSH(A4). As a result, the function returns the #NUM! error because A4 is a reference to an empty cell which is casted to 0. 114 ACOT Calculates the arccotangent, that is the inverse cotangent of a given number, and returns an angle, in radians, between 0 (zero) and π. Syntax =ACOT(value) value — a real number of which the arccotangent is to be calculated. Notes • The returned value is in radians, in the range of 0 (zero) to π. • If the value argument is specified as a non-numeric value, ACOT returns the #VALUE! error. • To get the result in degrees, you can use the DEGREES function or multiply the returned result by 180/PI(). Examples 1 A B Data Result 2 3 C D E 0.463647609 5 0.19739556 4 1. Formula entered in the B2 cell is as follows =ACOT(2). As a result, the function returns the arccotangent of 2, that is equal to 0.463647609 in radians. 2. Formula entered in the B3 cell is as follows =ACOT(A3). As a result, the function returns the arccotangent of 5, that is equal to 0.19739556 in radians. 115 ASIN Calculates the arcsine, that is the inverse arcsine of a given number, and returns an angle expressed in radians. Syntax =ASIN(value) value — a number for which the arcsine is to be calculated. It must be between -1 and 1, inclusive. Notes • If value is beyond the limit values (from -1 to 1), the #NUM! error is displayed. • ASIN supports numbers presented as strings, e.g. "1". The resulted value is recognized as a number. • If the argument is a cell reference with an empty value, ASIN evaluates it to 0 (zero). • If value is expressed in degrees, use the RADIANS function to convert the value to radians. Examples 1 A B C Data Result 2 0.775397497 3 0.903339111 4 -1.119769515 5 6 7 0.3 D E 0.304692654 #NUM! 0 8 1. Formula entered in the B2 cell is =ASIN(0.7). As a result, the function returns the arcsine of 0.7 expressed in radians. 116 2. Formula entered in the B3 cell is =ASIN(RADIANS(45)). As a result, the function coverts 45 degrees to radians, that is 0.785398163, and returns the arcsine of the output value. 3. Formula entered in the B4 cell is =ASIN("-0.9"). As a result, the function returns the arcsine of -0.9 ("-0.9" is cased to -0.9). The output value is expressed in radians. 4. Formula entered in the B5 cell is =ASIN(A5). As a result, the function returns the arcsine of the value in cell A5. The output value is expressed in radians. 5. Formula entered in the B6 cell is =ASIN(9). As a result, the function returns the #NUM! error as the supplied number is beyond the limit values. 6. Formula entered in the B7 cell is =ASIN(A7). As a result, the function returns the arcsine of 0 as A7 is a reference to an empty cell. 117 ATAN Calculates the arctangent, that is the inverse tangent of a given number, and returns an angle, in radians, between -Pi/2 and Pi/2. Syntax =ATAN(value) value — a number for which the inverse tangent is to be calculated. Notes • ATAN supports numbers presented as strings, e.g. "1". The resulted value is recognized as a number. • If the argument is a cell reference with an empty value, ATAN evaluates it to 0 (zero). • If value is expressed in degrees, use the RADIANS function to convert the value to radians. Examples 1 A B C Data Result 2 1.471127674 3 1.003884822 4 -1.128218396 5 6 12 D E 1.487655095 0 7 1. Formula entered in the B2 cell is =ATAN(10). As a result, the function returns the arctangent of 10 expressed in radians. 2. Formula entered in the B3 cell is =ATAN(RADIANS(90)). As a result, the function coverts 90 degrees to radians, that is 1.570796327, and returns the arctangent of the output value. 118 3. Formula entered in the B4 cell is =ATAN("-2.11"). As a result, the function returns the arctangent of -2.11 ("-2.11" is cased to -2.11). The output value is expressed in radians. 4. Formula entered in the B5 cell is =ATAN(A5). As a result, the function returns the arctangent of the value in cell A5. The output value is expressed in radians. 5. Formula entered in the B6 cell is =ATAN(A6). As a result, the function returns the arctangent of 0 as A6 is a reference to an empty cell. 119 ATAN2 Returns the arctangent of an angle between the x-axis and a segment starting from the origin (0,0) and ending at a specific point defined by the coordinate pair (x,y). The resulted value is expressed in radians. Syntax =ATAN2(x, y) x — the x coordinate of a segment endpoint for which to calculate an angle from the x-axis. y — the y coordinate of a segment endpoint for which to calculate an angle from the x-axis. Notes • The function supports numbers presented as strings, e.g. "10". The resulted value is recognized as a number. • To convert the resulted value in radians to degrees, use the DEGREES function. • Logical values are casted to numbers: TRUE – to 1 and FALSE – to 0 (zero). Examples 1 A B C Data Result 2 0.463647609 3 -123.690067526 4 FALSE D E 1.570796327 5 1. Formula entered in the B2 cell is =ATAN2(10, 5). As a result, the function calculates the arctangent of the point specified by the x and y coordinates (10, 5), in radians. 2. Formula entered in the B3 cell is =DEGREES(ATAN2(-4, -6)). As a result, the function calculates the arctangent of the point specified by the x and y coordinates 120 (-4, -6), that is equal to -2.15879893, in radians, and converts the resulted value to degrees. 3. Formula entered in the B4 cell is =ATAN2(A4, 1). As a result, the function calculates the arctangent of the point specified by the following coordinates: x=0 and y=1 (cell A4 contains FALSE that is casted to 0). 121 ATANH Calculates the inverse hyperbolic tangent for a number. Syntax =ATANH(value) value — a number for which the inverse hyperbolic tangent is to be calculated. It must be a number between -1 and 1, exclusive. Notes • ATANH supports numbers presented as strings, e.g. "0.5". The resulted value is recognized as a number. • If the argument is a cell reference with an empty value, it is casted to 0 (zero). • If value is beyond the limit values (from -1 to 1), the #NUM! error is displayed. Examples 1 A B C Data Result 2 -0.309519604 3 0 4 5 0.9 D E 1.47221949 #NUM! 6 1. Formula entered in the B2 cell is =ATANH(-0.3). As a result, the function returns the hyperbolic arctangent of -0.3, that is equal to -0.309519604. 2. Formula entered in the B3 cell is =ATANH(A3). As a result, the function returns the hyperbolic arctangent of 0 as A3 is a reference to an empty cell. 3. Formula entered in the B4 cell is =ATANH(A4). As a result, the function returns the hyperbolic arctangent of 0.9, that is equal to 1.47221949. 122 4. Formula entered in the B5 cell is =ATANH(12). As a result, the function returns the #NUM! error as the supplied value is above the upper limit. 123 COSH Calculates the hyperbolic cosine for a real number. Syntax =COSH(value) value — a real number for which the hyperbolic cosine is to be calculated. Notes • COSH supports numbers presented as strings, e.g. "1". The resulted value is recognized as a number. • If the value argument is a reference to an empty cell, it is casted to 0 (zero). • If the value argument is specified as a non-numeric value, the #VALUE! error is displayed. Examples 1 A B Data Result 2 3 4 C D E 1 n/a #VALUE! 10.067661996 5 1. Formula entered in the B2 cell is =COSH(A2). An empty value in cell A2 is casted to 0. As a result, the function returns the hyperbolic cosine of 0, that is equal to 1. 2. Formula entered in the B3 cell is =COSH(A3). As a result, the function returns the #VALUE! error because the supplied argument is not a numeric value. 3. Formula entered in the B4 cell is =COSH(-3). As a result, the function returns the hyperbolic cosine of -3, that is equal to 10.067661996. 124 COTH Calculates the hyperbolic cotangent of a number. Syntax =COTH(angle) angle — a number, representing an angle in radians, for which the hyperbolic cotangent is to be calculated. Notes • COTH supports numbers presented as strings, e.g. "3". The resulted value is recognized as a number. • If angle is 0 (zero), the #DIV/0! error is displayed. • If the argument is a cell reference with an empty value, it is casted to 0 (zero). Examples 1 2 3 4 A B C Data Result D E 1.00067115 #DIV/0! -8 -1.000000225 5 1. Formula entered in the B2 cell is =COTH(4). As a result, the function returns the hyperbolic cotangent of 4, that is equal to 1.00067115. 2. Formula entered in the B3 cell is =COTH(A3). As a result, the function returns the #DIV/0! error as A3 is a reference with an empty value, that is casted to 0. 3. Formula entered in the B4 cell is =COTH(A4). As a result, the function returns the hyperbolic arctangent of -8, that is equal to -1.000000225. 125 CSC Calculates the cosecant of a number and returns the result in radians. Syntax =CSC(angle) angle — a number, representing an angle in radians, for which the cosecant is to be calculated. Notes • The function supports numbers presented as strings, e.g. "10". The resulted value is recognized as a number. • To convert the resulted value in radians to degrees, use the DEGREES function. • If the supplied argument equals 0, the #DIV/0! error is displayed. • Logical values are casted to numbers: TRUE – to 1 and FALSE – to 0 (zero). Examples 1 A B C Data Result 2 -1.863679598 3 67.335224101 4 5 D E FALSE #DIV/0! -31.5 -11.908383231 6 1. Formula entered in the B2 cell is =CSC(12). As a result, the function returns the cosecant of 12, that is equal to -1.863679598. 2. Formula entered in the B3 cell is =DEGREES(CSC(45)). As a result, the function calculates the cosecant of 45 and converts the resulted value in radians to degrees. 3. Formula entered in the B4 cell is =CSC(A4). As a result, the function returns the #DIV/0! error as the value in cell A4 is casted to 0. 126 4. Formula entered in the B5 cell is =CSC(A5). As a result, the function returns the cosecant of the value in cell A5. The output value is expressed in radians. 127 CSCH Calculates the hyperbolic cosecant of a number and returns the result in radians. Syntax =CSCH(angle) angle — a number, representing an angle in radians, for which the hyperbolic cosecant is to be calculated. Notes • The function supports numbers presented as strings, e.g. "10". The resulted value is recognised as a number. • To convert the resulted value in radians to degrees, use the DEGREES function. • If the supplied argument equals 0, the #DIV/0! error is displayed. • Logical values are casted to numbers: TRUE – to 1 and FALSE – to 0 (zero). Examples 1 A B C Data Result 2 8.37E-51 3 1.96E-13 4 5 D E FALSE #DIV/0! -23 -2.05E-10 6 1. Formula entered in the B2 cell is =CSCH(116). As a result, the function returns the hyperbolic cosecant of 116, that is equal to 8.37E-51. 2. Formula entered in the B3 cell is =DEGREES(CSCH(34)). As a result, the function calculates the hyperbolic cosecant of 34 and converts the resulted value in radians to degrees. 128 3. Formula entered in the B4 cell is =CSCH(A4). As a result, the function returns the #DIV/0! error as the value in cell A4 is casted to 0. 4. Formula entered in the B5 cell is =CSCH(A5). As a result, the function returns the hyperbolic cosecant of the value in cell A5. The output value is expressed in radians. 129 DEGREES Converts an angle value in radians to the equivalent value in degrees. Syntax =DEGREES(angle) angle — an angle value in radians to be converted to degrees. Examples 1 A B C Data Result 2 57.295779513 3 180 4 0.5 28.647889757 D E 5 1. Formula entered in the B2 cell is =DEGREES(COS(0)). As a result, the function converts the cosine of 0 expressed in radians to the value in degrees, that is equal to 57.295779513. 2. Formula entered in the B3 cell is =DEGREES(PI()). As a result, the function converts the 3.141592654 angle value in radians to the value in degrees, that is equal to 180. 3. Formula entered in the B4 cell is =DEGREES(A4). As a result, the function converts the angle value in cell A4 expressed in radians to the value in degrees, that is equal to 28.647889757. 130 EXP Returns the e number (∼2.718) raised to a supplied power. Syntax =EXP(exponent) exponent — the power to which the e constant is raised. Notes • exponent can be any real number within the editor’s limits. Exceeding the lower and higher thresholds results in 0 and the #NUM! error respectively. • EXP supports numbers presented as strings, e.g. "12". • For the inverse function, natural logarithm of a number, see LN. Examples A B C 1 Data Result 2 -4 2.5 12.182493961 4 1 6 E 0.018315639 3 5 D 800 #NUM! -800 0 7 1. Formula entered in the B2 cell is =EXP(A2). The function raises the e constant to the power of -4 and returns 0.018315639. 2. Formula entered in the B3 cell is =EXP(A3). The function raises the e constant to the power of 2.5 and returns 12.182493961. 3. Formula entered in the B4 cell is =EXP(0). The function raises the e constant to the power of 0 and returns 1. 131 4. Formula entered in the B5 cell is =EXP(A5). The function raises the e constant to the power of 800 and returns the #NUM! error because the result exceeds the editor’s higher threshold. 5. Formula entered in the B6 cell is =EXP(A6). The function raises the e constant to the power of -800 and returns 0 because the result exceeds the editor’s lower threshold. 132 FACTDOUBLE Returns the double factorial of a number. Syntax =FACTDOUBLE(value) value — a number which double factorial is to be calculated. Notes • If the argument contains a decimal number, its fractional part is dropped. • The function supports numbers presented as strings, e.g. "10". The resulted value is recognized as a number. • Logical values are casted to numbers: TRUE – to 1 and FALSE – to 0 (zero). • The supplied number must be greater than or equal to 0; otherwise, the #NUM! error is displayed. Examples 1 A B Data Result 2 3 C D E 945 TRUE 1 4 -34 #NUM! 5 945 6 1. Formula entered in the B2 cell is =FACTDOUBLE(9). As a result, the function returns the double factorial of 9, that is equal to 945. 2. Formula entered in the B3 cell is =FACTDOUBLE(A3). As a result, the function returns the double factorial of 1 (TRUE is casted to 1), that is equal to 1. 3. Formula entered in the B4 cell is =FACTDOUBLE(A4). As a result, the function returns the #NUM! error as cell A4 contains a negative number. 133 4. Formula entered in the B5 cell is =FACTDOUBLE(9.78). As a result, the function ignores the fractional part of the supplied number and calculates the double factorial of 9, that is equal to 945. 134 INT Rounds a number down to the nearest integer. Syntax =INT(value) value — a number to round down to the nearest integer. Notes • INT handles real numbers that include positive (e.g. 14), negative (e.g. -5), rational (e.g. 1.3), and irrational (PI = 3.1415926) numbers. • INT supports numbers presented as strings, e.g. "12". The resulted value is recognized as a number. Examples A B C 1 Data Result 2 8 3 -3.7 -4 4 0.25 0 D E 5 1. Formula entered in the B2 cell is =INT("8.8"). As a result, the function rounds 8.8 down to the nearest integer ("8.8" is casted to 8.8) and returns 8. 2. Formula entered in the B3 cell is =INT(A3). As a result, the function rounds the value in cell A3 down to the nearest integer and returns -4. 3. Formula entered in the B4 cell is =INT(A4). As a result, the function rounds the value in cell A4 down to the nearest integer and returns 0. 135 LN Returns the logarithm of a number to base e (∼2.718) which is known as the natural logarithm. Syntax =LN(value) value — a value for which the natural logarithm is to be calculated. Notes • The supplied value must be a positive number. Otherwise, the #NUM! error is returned. • LN supports numbers presented as strings, e.g. "12". The resulted value is recognized as a number. • Logical values are casted to numbers: TRUE – to 1 and FALSE – to 0 (zero). Examples 1 A B C Data Result 2 6 1.791759469 3 1.098612289 4 5 D E -4 #NUM! TRUE 0 6 1. Formula entered in the B2 cell is =LN(A2). As a result, the function returns the natural logarithm of 6, that is equal to 1.791759469. 2. Formula entered in the B3 cell is =LN(3). As a result, the function returns the natural logarithm of 3, that is equal to 1.098612289. 3. Formula entered in the B4 cell is =LN(A4). As a result, the function returns the #NUM! error value as a negative number is supplied to the argument. 136 4. Formula entered in the B5 cell is =LN(A5). As a result, the function returns the natural logarithm of 1 (TRUE is casted to 1), that is equal to 0. 137 LOG Returns the logarithm of a number with respect to a given base. Syntax =LOG(value, [base]) value — a value for which to calculate the logarithm to a given base. [base] (optional) — a base to be used to calculate the logarithm. If the argument is omitted, 10 is used by default. Notes • Both value and base values must be positive; otherwise, LOG returns the #NUM! error value. • LOG supports numbers presented as strings, e.g. "3". The resulted value is recognized as a number. Examples A B C 1 Data Result 2 2 3 2 4 #NUM! 5 6 9 D E 2 1 7 1. Formula entered in the B2 cell is =LOG("4", 2). As a result, the function returns the logarithm of 4 ("4" is cased to 4) to base 2, that is equal to 2. 2. Formula entered in the B3 cell is =LOG(25, 5). As a result, the function returns the logarithm of 25 to base 5, that is equal to 2. 3. Formula entered in the B4 cell is =LOG(-5, 4). As a result, the function returns the 138 #NUM! error because a negative number is specified as an argument. 4. Formula entered in the B5 cell is =LOG(A5, 3). As a result, the function returns the logarithm of 9 (cell A5) to base 3, that is equal to 2. 5. Formula entered in the B6 cell is =LOG(10). As a result, the function returns the logarithm of 10 to base 10, that is equal to 1. 139 LOG10 Returns the base-10 logarithm of a given number. Syntax =LOG10(value) value — a number for which the base-10 logarithm is to be calculated. It must be a positive number. Notes • If value is zero or a negative number, the #NUM! error is returned. • LOG10 supports presenting numbers as a string, e.g. "12". The resulted value is recognized as a number. Examples 1 A B C Data Result 2 3 3 15 1.176091259 4 #NUM! 5 0.698970004 D E 6 1. Formula entered in the B2 cell is =LOG10(10^3). As a result, the function returns the base-10 logarithm of 10^3 (1000), that is equal to 3. 2. Formula entered in the B3 cell is =LOG10(A3). As a result, the function returns the base-10 logarithm of 15, that is equal to 1.176091259. 3. Formula entered in the B4 cell is =LOG10(-5). As a result, the function returns the #NUM! error because the supplied argument is a negative number. 4. Formula entered in the B5 cell is =LOG10("5"). As a result, the function returns 140 the base-10 logarithm of 5 ("5" presented as a string is casted to 5), that is equal to 0.698970004. 141 PI Returns the pi value rounded to 14 decimal places. Syntax =PI() Examples 1 A B C Data Result 2 3.141592654 3 6.283185307 4 1.144729886 D E 5 1. Formula entered in the B2 cell is =PI(). As a result, the function returns the value of pi, that is equal to 3.141592654. 2. Formula entered in the B3 cell is =PI()+PI(). As a result, the function returns the sum of pi values, that is equal to 6.283185307. 3. Formula entered in the B4 cell is =LN(PI()). As a result, the function returns the natural logarithm of pi, that is equal to 1.144729886. 142 POWER Returns a result of raising a number to a power. Syntax =POWER(base, exponent) base — a base number to be raised to the exponent power. exponent — an exponent to which to raise base. Notes • POWER supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. • As an alternative to the POWER function, you can use a caret (^) to raise a number to a power. In other words, entering =2^3 is equivalent to =POWER(2, 3). Examples 1 A B C Data Result 2 759375 3 1 4 43 5 12 3.464101615 D E 79507 6 1. Formula entered in the B2 cell is as follows =POWER("15", 5). As a result, the function raises 15 to the power of 5 ("15" presented as a string is casted to 15). 2. Formula entered in the B3 cell is as follows =POWER(-1, -2). As a result, the function raises -1 to the power of -2. 3. Formula entered in the B4 cell is as follows =POWER(A4, 3). As a result, the function raises the value in cell A4 to the power of 3. 143 4. Formula entered in the B5 cell is as follows =POWER(A5, 0.5). As a result, the function raises the value in cell A5 to the power of 0.5. 144 PRODUCT Returns the product of supplied arguments. Syntax =PRODUCT(factor1, [factor2, ...]) factor1 — the first number or set of numbers to be multiplied. [factor2, ...] (optional) — additional numbers or sets of numbers to be multiplied. Notes • A set of numbers can be presented as a cell range or an array. • If PRODUCT receives only one argument, it returns the factor1 value. • PRODUCT ignores empty cells, logical or text values within a supplied array or cell range. If all arguments are ignored, the function returns 0. • PRODUCT supports numbers presented as strings, e.g. "15". • The maximum number of arguments is 255. 145 Examples A 1 B C D E Data Result 2 10 32 3 23 180 4 2 598 5 13 20332 6 34 442 7 price 576 8 1. Formula entered in the B2 cell is =PRODUCT("8", "4"). As a result, the function casts strings into numbers and returns their product. 2. Formula entered in the B3 cell is =PRODUCT(15, 2, 6). As a result, the function multiplies the numbers supplied directly to the formula. 3. Formula entered in the B4 cell is =PRODUCT(A3:A5). As a result, the function multiplies the numbers in cells A3 through A5. 4. Formula entered in the B5 cell is =PRODUCT(A3:A5, A6, 1). As a result, the function multiplies the numbers from cells A3 through A5, the number from the A6 cell, and the constant. 5. Formula entered in the B6 cell is =PRODUCT(A5, A6). As a result, the function multiplies the numbers from separate cells. 6. Formula entered in the B7 cell is =PRODUCT({1,2;3,4}, {1,2;3,4}, A7). As a result, the function ignores the string in the A7 cell and multiplies the numbers from the supplied arrays. 146 QUOTIENT Divides a number by another one and returns a value without a reminder. Syntax =QUOTIENT(dividend, divisor) dividend — a number to be divided. divisor — a number to be divided by another number. Notes • Under the standard math rules, division by 0 is forbidden. Thus, the function returns the #DIV/0! error if divisor equals 0. • QUOTIENT supports numbers presented as strings, e.g. "12". The resulted value is recognized as a number. • Logical values are casted to numbers: TRUE – to 1 and FALSE – to 0 (zero). Examples 1 2 A B Data Result -25 C 14 4 56 #DIV/0! FALSE E -8 3 5 D 0 6 1. Formula entered in the B2 cell is =QUOTIENT(A2, 3). As a result, the function divides -25 by 3 and returns -8 without a reminder. 2. Formula entered in the B3 cell is =QUOTIENT(28, 2). As a result, the function divides 28 by 2 and returns 14. 3. Formula entered in the B4 cell is =QUOTIENT(A4, 0). As a result, the function returns the #DIV/0! error as the divisor argument is set to 0. 147 4. Formula entered in the B5 cell is =QUOTIENT(A5, 6). As a result, the function divides 0 by 6 (FALSE is casted to 0) and returns 0. 148 RAND Returns a random decimal number between 0 and 1, excluding the boundary values. Syntax =RAND() Notes • By default, the function selects a random decimal in the range from 0 to 1. To expand the range, enter an asterisk (*) followed by a boundary value after the formula. For example, enter =RAND()*100 to get a random decimal between 0 and 100. • The function returns different results every time the formula is calculated or recalculated. Examples 1 A B C Data Result 2 0.756613941 3 15.853673339 4 -19.389000136 D E 5 1. Formula entered in the B2 cell is =RAND(). As a result, the function returns a random decimal number that falls between 0 and 1, excluding the boundary values. The output value varies on every calculation. 2. Formula entered in the B3 cell is =RAND()*22. As a result, the function returns a random decimal number that falls between 0 and 22, excluding the boundary values. The output value varies on every calculation. 3. Formula entered in the B4 cell is =RAND()*-90. As a result, the function returns a random decimal number that falls between -90 and 0, excluding the boundary values. The output value varies on every calculation. 149 ROUND Rounds a number to a certain number of digits according to standard rounding rules. Syntax =ROUND(value, places) value — a number to be rounded. places — the number of digits to which to round. Notes • The function rounds a number to a particular place according to standard rules, i.e. the next most significant digit (digit to the right) is considered. If a digit is greater than or equal to 5, a number is rounded up; otherwise, it is rounded down. • If places is positive, value is rounded to the right of the decimal point. • If places is negative, value is rounded to the left of the decimal point. • If places is 0, value is rounded to the nearest integer. Examples A B C 1 Data Result 2 46.345 50 3 36.909 36.91 4 20.3 20 D E 5 1. Formula entered in the B2 cell is as follows =ROUND(A2, -1). As a result, the function rounds the number in cell A2 to one decimal place to the left of the decimal point. 2. Formula entered in the B3 cell is as follows =ROUND(A3, 2). As a result, the function rounds the number in cell A3 to two decimal places to the right of the decimal point. 150 3. Formula entered in the B4 cell is as follows =ROUND(A4, 0). As a result, the function rounds the value in cell A4 to the nearest integer. 151 ROUNDDOWN Rounds a number down to a certain number of decimal places. Syntax =ROUNDDOWN(value, places) value — a number to be rounded down. places — the number of decimal places to which to round value down. Notes • If places is a negative number, value is rounded down to the left of the decimal point. For example, =ROUNDDOWN(46.78, -1) rounds 46.78 down to the nearest multiple of 10 and returns 40. • If places is a positive number, value is rounded down to the right of the decimal point. • If places is 0, value is rounded down to the nearest integer. • ROUNDDOWN supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. Examples 1 A B C Data Result 2 94.81 3 122000 4 67.6 60 5 347.907 347 D E 6 1. Formula entered in the B2 cell is as follows =ROUNDDOWN(94.81032, 2). As a result, the function rounds the number down to two decimal places to the right of the decimal point. 152 2. Formula entered in the B3 cell is as follows =ROUNDDOWN("122905.67", -3). As a result, the function rounds the number value down to three decimal places to the left of the decimal point ("122905.67" presented as a string is casted to 122905.67). 3. Formula entered in the B4 cell is as follows =ROUNDDOWN(A4, -1). As a result, the function rounds the number in cell A4 down to the nearest multiple of 10. 4. Formula entered in the B5 cell is as follows =ROUNDDOWN(A5, 0). As a result, the function rounds the value in cell A5 down to the nearest integer. 153 ROUNDUP Rounds a number up to a certain number of digits. Syntax =ROUNDUP(value, places) value — a number to be rounded up. places — the number of digits to which to round value up. Notes • If places is a negative number, value is rounded up to the left of the decimal point. For example, =ROUNDUP(12.67, -1) rounds 12.67 up to the nearest multiple of 10 and returns 20. • If places is a positive number, value is rounded up to the right of the decimal point. • If places is 0, value is rounded up to the nearest integer. • ROUNDUP supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. Examples A B 1 Data Result 2 53.891 3 4 5 C D E 60 87.81 200.213 201 1200 6 1. Formula entered in the B2 cell is as follows =ROUNDUP(A2, -1). As a result, the function rounds the number in cell A2 up to the nearest multiple of 10. 2. Formula entered in the B3 cell is as follows =ROUNDUP(87.800347, 2). As a result, the function rounds the number up to two decimal places to the right of the decimal point. 154 3. Formula entered in the B4 cell is as follows =ROUNDUP(A4, 0). As a result, the function rounds the value in cell A4 up to the nearest integer. 4. Formula entered in the B5 cell is as follows =ROUNDUP("1149.67", -2). As a result, the function rounds the number up to two decimal places to the left of the decimal point ("1149.67" presented as a string is casted to 1149.67). 155 SEC Returns the secant of an angle, in radians. Syntax =SEC(angle) angle — an angle, in radians, for which the secant is to be calculated. Notes • SEC supports numbers presented as strings, e.g. "23". The resulted value is recognized as a number. • If the angle argument is specified as a non-numeric value, the #VALUE! error is displayed. • If the angle argument is a reference to an empty cell, it is casted to 0 (zero). Examples 1 A B Data Result 2 3 4 C D E 1 n/a #VALUE! 1.185039176 5 1. Formula entered in the B2 cell is =SEC(A2). An empty value in cell A2 is casted to 0. As a result, the function returns the secant of 0, that is equal to 1. 2. Formula entered in the B3 cell is =SEC(A3). As a result, the function returns the #VALUE! error because the supplied argument is not a numeric value. 3. Formula entered in the B4 cell is =SEC(-12). As a result, the function returns the secant of -12, that is equal to 1.185039176. 156 SECH Returns the hyperbolic secant of an angle. Syntax =SECH(angle) angle — an angle, in radians, of which the hyperbolic secant is to be calculated. Notes • If the angle argument is specified as a non-numeric value, SECH returns the #VALUE! error. • If the angle argument is a reference to an empty cell, SECH returns 1, that is the hyperbolic secant of 0. Examples 1 A B C Data Result 2 1 3 #VALUE! 4 1.18E-28 5 90 1.64E-39 6 1 D E 7 1. Formula entered in the B2 cell is as follows =SECH(0). As a result, the function returns the hyperbolic secant of the specified angle, that is equal to 1. 2. Formula entered in the B3 cell is as follows =SECH("45degrees"). As a result, the function returns the #VALUE! error because the supplied argument is not a numeric value (it is a string). 3. Formula entered in the B4 cell is as follows =SECH(65). As a result, the function returns the hyperbolic secant of a 65 degree angle, that is equal to 1.18E-28. 157 4. Formula entered in the B5 cell is as follows =SECH(A5). As a result, the function returns the hyperbolic secant of a 90 degree angle, that is equal to 1.64E-39. 5. Formula entered in the B6 cell is as follows =SECH(A6). As a result, the function returns the hyperbolic secant of 0 as A6 is an empty cell. 158 SINH ez − e−z SIN H(z) = 2 Returns the hyperbolic sine of a number. Syntax =SINH(value) value — a number for which the hyperbolic sine is to be calculated. It can be any real number. Examples 1 A B C Data Result 2 0.521095305 3 3.626860408 4 4 27.289917197 D E 5 1. Formula entered in the B2 cell is =SINH(0.5). As a result, the function returns the hyperbolic sine of 0.5, that is equal to 0.521095305. 2. Formula entered in the B3 cell is =SINH(2). As a result, the function returns the hyperbolic sine of 2, that is equal to 3.626860408. 3. Formula entered in the B4 cell is =SINH(A4). As a result, the function returns the hyperbolic sine of 4, that is equal to 27.289917197. 159 SQRT Returns the positive square root of a number. Syntax =SQRT(value) value — a number for which the positive square root is to be calculated. Notes • If value is negative, SQRT returns the #NUM! error. • SQRT supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. Examples A 1 2 B C D E Data Result 9 3 3 5 4 -45 #NUM! 5 1. Formula entered in the B2 cell is as follows =SQRT(A2). As a result, the function returns the square root of the value in cell A2. 2. Formula entered in the B3 cell is as follows =SQRT("25"). As a result, the function returns the square root of the number ("25" presented as a string is casted to 25). 3. Formula entered in the B4 cell is as follows =SQRT(A4). As a result, the function returns the #NUM! error because the supplied value is negative. 160 SQRTPI Returns the square root of the pi constant (3.14159265358979) multiplied by a given number. Syntax =SQRTPI(value) value — a number by which to multiply the pi constant to get the positive square root. It must be any positive number. Notes • If value is less than 0, the #NUM! error is displayed. • SQRTPI supports numbers presented as strings, e.g. "12". The resulted value is recognized as a number. Examples 1 A B C Data Result 2 2.802495608 3 5 3.963327298 4 D E #NUM! 5 1. Formula entered in the B2 cell is =SQRTPI(2.5). As a result, the function returns the square root of 2.5*pi, that is equal to 2.802495608. 2. Formula entered in the B3 cell is =SQRTPI(A3). As a result, the function returns the square root of 5*pi, that is equal to 3.963327298. 3. Formula entered in the B4 cell is =SQRTPI(-5). As a result, the function returns the #NUM! error because the supplied argument is a negative number. 161 SUBTOTAL Uses another function to calculate a subtotal (sum, product, and so on) for a set of numbers. Syntax =SUBTOTAL(function_code, range1, [range2, ...]) function_code — a numeric code, which indicates the function you want to use for the subtotal. Use codes 1—11 to include manually hidden cells or 101—111 to ignore them. range1 — the first range or array for which to calculate the subtotal. [range2, ...] (optional) — additional ranges or arrays to include in the subtotal. function_code (with hidden cells) 1 function_code (without hidden cells) 101 Function 2 102 COUNT 3 103 COUNTA 4 104 MAX 5 105 MIN 6 106 PRODUCT 7 107 STDEV.S 8 108 STDEV.P 9 109 SUM 10 110 VAR 11 111 VAR.P AVERAGE Notes • Cells that are hidden by a filter are always excluded from the subtotal. If you want the function to treat such cells as manually hidden ones, you must first reveal them with a filter and only then hide them manually. • When you collapse sections with grouped rows or columns, cells from these sections 162 are treated as manually hidden ones. • Aggregates and other subtotals are always excluded from the subtotal. • When this function ignores all values from a supplied set, it returns the #VALUE! error. Examples A 1 Hidden by filter 3 120 Hidden manually 7 560 Data B C D Result Include Ignore hidden hidden 2 4 180 3 3 5 240 5 4 6 320 15 15 8 880 9 #VALUE! 1. The formula in the B4 cell is =SUBTOTAL(2, A1:A6). The given code matches COUNT and specifies that manually hidden cells must be included in the count (the condition has no effect because the range has no such cells). The A3 cell is ignored because it is hidden by the filter. 2. The formula in the B5 cell is =SUBTOTAL(2, A1:A8). The given code matches COUNT and specifies that manually hidden cells must be included in the count (as a result, the number in the A7 cell is counted). The A3 cell is excluded from the count because it is hidden by the filter. 3. The formula in the C5 cell is =SUBTOTAL(102, A1:A8). The given code matches COUNT and specifies that manually hidden cells must be excluded from the count (as a result, the number in the A7 cell is ignored). The A3 cell is excluded from the count because it is hidden by the filter. 4. The formula in the B6 cell is =SUBTOTAL(9, {1, 2, 3, 4, 5}). The given code matches SUM and specifies that manually hidden cells must be included in the sum (the condition has no effect because the array has no manually hidden cells). 5. The formula in the C9 cell is =SUBTOTAL(1, B4:B6, AGGREGATE(9, 4, 1, 2, 163 3)). The function ignores all supplied sets (three subtotals and one aggregate) and returns the #VALUE! error. 164 SUM A+B =C Returns a result of adding all individual values, cell references or ranges or a mix of all three. Syntax =SUM(value1, [value2, ...]) value1 — the first value to be added. [value2, ...] (optional) — additional values or ranges to add to value1. Notes • SUM supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. • SUM ignores empty cells and text values which may be in the range considered in the calculation. • A text value supplied directly to the formula argument causes the #VALUE! error. If a supplied value is non-numeric other than a text value, SUM ignores it and returns 0. • If the TRUE and FALSE logical values are entered directly to the formula arguments, they are casted to 1 and 0, respectively. Otherwise, SUM ignores such values. • As an alternative to the SUM function, you can use a plus (+) sign to get the sum of numbers. In other words, entering =2+3 is equivalent to =SUM(2, 3). • The maximum number of the function arguments is limited to 255. 165 Examples A B C 1 Data Result 2 25 157 3 43 157 4 89 44 5 87 245 6 TRUE #VALUE! 7 value 8 D E 0 2 9 1. Formula entered in the B2 cell is as follows =SUM(A2, A3, A4). As a result, the function sums the values stored in separate cells. 2. Formula entered in the B3 cell is as follows =SUM(A2:A4). As a result, the function calculates the sum across the A2:A4 range. 3. Formula entered in the B4 cell is as follows =SUM("25", "19"). As a result, the function sums the numbers and converts the resulted value into its numeric representation ("25" and "19" presented as a string are casted to 25 and 19, respectively). 4. Formula entered in the B5 cell is as follows =SUM(A2:A4, A5, 1). As a result, the function sums up mixed forms of numeric data, including static numbers. 5. Formula entered in the B6 cell is as follows =SUM("value", 56). As a result, the function returns the #VALUE! error value as a text value is entered directly to the formula argument. 6. Formula entered in the B7 cell is as follows =SUM(A6:A7). As a result, the function returns 0 as the values in the range are non-numeric. 7. Formula entered in the B8 cell is as follows =SUM(TRUE, TRUE). As a result, the function returns 2 as the TRUE logical value, if entered directly to the formula argument, is casted to 1. 166 SUMIF Returns the sum of a range of values matching a certain criterion. Syntax =SUMIF(range, criterion, [sum_range]) range — a range of cells to be tested against criterion. criterion — a condition to apply to range. [sum_range] (optional) — a range of values to be summed if the corresponding values in range meet criterion. Notes • Text criteria, criteria containing mathematical symbols, and wildcard characters must be enclosed in double quotation marks, e.g. "value". • Uppercase and lowercase text criteria are considered equivalent. • Wildcard characters allow you to filter a list of text data based on a supplied condition and sum values by partial match. • The sum_range argument can be set as a reference. It is then assumed that the reference is an upper leftmost cell of the range to be summed. In this case, the range is automatically expanded to the size of the first range. • Several mathematical symbols specified as part of a criterion must be entered without spaces, e.g. "<= 40". • SUMIF allows specifying multiple conditions to be applied to a single range. To do this, enter the conditions as an array, e.g. {1,2,3}. 167 Examples A 1 Month 2 June 3 B C D E Sales Result $800 6100 July $1,200 9250 4 August $3,000 2000 5 September $2,250 3500 6 October $1,500 5500 7 November $3,100 5250 8 December $2,400 9 1. Formula entered in the C2 cell is as follows =SUMIF(B2:B8, ">= $3,000"). As a result, the function considers the B2:B8 range and sums the values greater than or equal to $3,000. 2. Formula entered in the C3 cell is as follows =SUMIF(A2:A8, "*er", B2:B8). As a result, the function sums the values in the B2:B8 range if the corresponding text values in A2:A8 end with -er. 3. Formula entered in the C4 cell is as follows =SUMIF(A2:A8, "J*", B2). As a result, the function sums the values in the B2:B8 range (as B2 is assumed as the B2:B8 range) if the corresponding text values in A2:A8 start with letter J. 4. Formula entered in the C5 cell is as follows =SUMIF(B2:B8, "< $2,000"). As a result, the function considers the B2:B8 range and sums the values less than $2,000. 5. Formula entered in the C6 cell is as follows =SUMIF(A2:A8, "??????er", B2:B8). As a result, the function sums the values in the B2:B8 range if the corresponding values in A2:A8 contain the 8-character long values ending with -er. 6. Formula entered in the C7 cell is as follows =SUM(SUMIF(A2:A8, {"August", "September"}, B2:B8)). As a result, the function sums the values in the B2:B8 range if the corresponding values in A2:A8 contain "September", "August". 168 SUMIFS Returns the sum of a range of values matching multiple criteria. Syntax =SUMIFS(sum_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...]) sum_range — a range containing values to calculate the sum. criteria_range1 — a range to be checked against criterion1. criterion1 — a condition to apply to criteria_range1. [criteria_range2, criterion2, ...] (optional) — additional ranges and conditions to consider. Notes • Text criteria, criteria containing mathematical symbols and wildcard characters must be enclosed in double quotation marks, e.g. "value". • Several mathematical symbols specified as part of a criterion must be entered without spaces, e.g. "<= 40". • Uppercase and lowercase text values are considered as equivalent. • Wildcard characters allow you to filter a list of text data based on a supplied condition and sum values by partial match. • Ranges or arrays considered in the calculation must be equal in size. • The number of the criteria_range arguments must equal the number of the criterion arguments. Otherwise, the function returns the #VALUE! error. • SUMIFS allows specifying multiple conditions to be applied to a single range. To do this, enter the conditions as an array, e.g. {1,2,3}. • The maximum number of the function arguments is limited to 255. 169 Examples A B C D 1 Name Month 2 Jane September $1,210 4674 3 Jane October $1,560 4725 4 Jane November $1,904 6319 5 Jack September $2,400 2460 6 Jack October $1,645 4105 7 Jack November $2,821 2110 8 Kate October E Salary Result $900 9 1. Formula entered in the D2 cell is as follows =SUMIFS(C2:C8, A2:A8, "Jane"). As a result, the function sums the values in the C2:C8 range if the corresponding cells in column A contain the "Jane" text values. 2. Formula entered in the D3 cell is as follows =SUMIFS(C2:C8, B2:B8, "november", C2:C8, ">$1,500"). As a result, the function considers the C2:C8 range and sums the values larger than $1,500 if the corresponding cells in column B contain the "november" text values. 3. Formula entered in the D4 cell is as follows =SUMIFS(C2:C8, A2:A8, "J*", C2:C8, "<$2,000"). As a result, the function considers the C2:C8 range and sums the values less than $2,000 if the corresponding cells in column A contain text values starting with letter J. 4. Formula entered in the D5 cell is as follows =SUMIFS(C2:C8, A2:A8, "???e", B2:B8, "October"). As a result, the function sums the values in the C2:C8 range if the corresponding cells in column A contain 4-character values ending with -e, and cells in column B match the "October" text entry. 5. Formula entered in the D6 cell is as follows =SUMIFS(C2:C8, B2:B8,"October", C2:C8, "<$1,900"). As a result, the function considers the C2:C8 range and sums the values less than $1,900 if the corresponding cells in column B contain the "October" value. 170 6. Formula entered in the D7 cell is as follows =SUM(SUMIFS(C2:C8, A2:A8, {"Jane", "Kate"}, B2:B8, {"September", "October"})). As a result, the function returns the sum of Jane’s salary in September and Kate’s salary in October. 171 SUMPRODUCT (A × B) + (C × D) = E Multiplies ranges or arrays together and returns the sum of products. Syntax =SUMPRODUCT(array1, [array2, ...]) array1 — the first array or range which components are to be multiplied and then added. [array2, ...] (optional) — the second array or range which components are to be multiplied and then added. Notes • If a single array or range is supplied, SUMPRODUCT returns the sum of numbers in an array or a range. • Arrays or ranges considered in the calculation must be equal in size; otherwise, SUMPRODUCT returns the #VALUE! error. • SUMPRODUCT evaluates non-numeric values in an array or a range to 0. • The priority sequence in calculations is determined by standard mathematical rules: multiplication comes before addition. • The maximum number of the function arguments is limited to 255. 172 Examples A 1 Item B C D E Price Amount Result 2 Apple 25 10 534 3 Banana 43 14 1601 4 Grapefruit 89 23 0 5 Peach 98 20 72 6 Mango 122 5 852 7 1. Formula entered in the D2 cell is as follows =SUMPRODUCT(B4:B5, {6; "text"}). As a result, the function multiplies the corresponding entries in 2 datasets where the last entries are multiplied by 0 and returns the sum of their products. That is 89*6 + 98*0. 2. Formula entered in the D3 cell is as follows =SUMPRODUCT(B3:B5,{7; 8; 6}). As a result, the function multiplies the corresponding entries in 2 datasets and returns the sum of their products. That is 43*7 + 89*8 + 98*6. 3. Formula entered in the D4 cell is as follows =SUMPRODUCT(A2:A4, B2:B4). As a result, the function multiplies the corresponding entries in 2 ranges containing various types of values and returns the sum of their products. That is 0*25 + 0*43 + 0*89. 4. Formula entered in the D5 cell is as follows =SUMPRODUCT(C2:C6). As a result, the function returns the sum of entries in the range. That is 10 + 14 + 23 + 20 + 5. 5. Formula entered in the D6 cell is as follows =SUMPRODUCT(B2:B3, C2:C3). As a result, the function multiplies the corresponding entries in two ranges and then adds their products. That is 25*10 + 43*14. 173 SUMSQ A2 + B 2 = C Returns the sum of the squares of numbers. Syntax =SUMSQ(value1, [value2, ...]) value1 — the first number, range, or array which squares are to be added together. [value2, ...] (optional) — additional numbers, ranges, or arrays which squares are to be added to the square(s) of the first argument. Notes • If a single number is considered in the calculation, SUMSQ returns the number squared. • The function ignores text values and logical values that may be in a range or an array. • Text values supplied directly to the formula arguments provokes the #VALUE! error. • SUMSQ supports representing numbers as text values, e.g. "12". The output value is recognized as a number. • When supplied directly to the formula arguments, logical values are casted to numbers: TRUE – to 1 and FALSE – to 0. • The maximum number of the function arguments is limited to 255. 174 Examples A B 1 Data Result 2 25 3 13 #VALUE! 4 n/a C D E 625 1534 5 8 4982 6 26 37 7 1. Formula entered in the B2 cell is =SUMSQ(A2). As a result, the function returns 25 squared, that is equal to 625. 2. Formula entered in the B3 cell is =SUMSQ("text", 6). As a result, the function returns the #VALUE! error as a text value is supplied directly to the argument. 3. Formula entered in the B4 cell is =SUMSQ(A2:A6). As a result, the function returns the sum of squares across the A2:A6 range, that is equal to 1534. 4. Formula entered in the B5 cell is =SUMSQ({"text", 5, 6, 18}, {4, 15, 66}). As a result, the function returns the sum of squares in the arrays, ignoring a text value. 5. Formula entered in the B6 cell is =SUMSQ(6, TRUE). As a result, the function returns the sum of squares of 6 and 1 (TRUE is casted to 1). 175 TANH Returns the hyperbolic tangent of a number. Syntax =TANH(value) value — a value for which the hyperbolic tangent is to be calculated. It can be any real number. Notes • TANH supports numbers treated as text values which must be enclosed in double quotation marks, e.g. "12". Examples 1 A B C Data Result 2 0.999909204 3 -5 -0.999909204 4 0.291312612 5 0 D E 6 1. Formula entered in the B2 cell is =TANH(5). As a result, the function returns the hyperbolic tangent of 5, that is equal to 0.999909204. 2. Formula entered in the B3 cell is =TANH(A3). As a result, the function returns the hyperbolic tangent of -5 (value specified in cell A3), that is equal to -0.999909204. 3. Formula entered in the B4 cell is =TANH(0.3). As a result, the function returns the hyperbolic tangent of 0.3, that is equal to 0.291312612. 4. Formula entered in the B5 cell is =TANH("0"). As a result, the function returns the hyperbolic tangent of 0 ("0" is casted to 0), that is equal to 0. 176 Chapter 7 Database functions 177 DSUM Calculates the sum of database values filtered by specified criteria. Syntax =DSUM(database, field, criteria) database — a cell range with column headers in the first row and a set of related data in each following row. field — a database column that contains values to be summed. criteria — a cell range with column headers in the first row and conditions for columns in each following row. Notes • field can be specified as a column number or a column header between double quotation marks. Number 1 matches the first column of database. • DSUM ignores letter case. • DSUM ignores text values inside field. • If criteria is an empty cell range or has an empty second row, DSUM calculates the sum of all values in field. • DSUM supports predicates (>,<, >=, <=, =, <>). • DSUM supports wildcard characters in criteria that contain text. By default, the function treats a question mark (?) as any single character and an asterisk (*) as any sequence of characters. To use an actual question mark or asterisk in criteria, type a tilde (~) before the character. 178 Examples A B C D E 1 Product Supplier Revenue Result 2 Puzzles Tom 240 776 3 Checkers Sam 435 1016 4 Darts 360 1030 5 Checkers Tom 341 1611 6 Puzzles 595 0 Peter Peter 7 675 8 Product Supplier Revenue 9 checkers ??m 10 p* >=400 <500 11 1. Formula entered in the D2 cell is =DSUM(A1:C6, 3, A8:A9). The function sums values from the third column if the corresponding cells in the Product column contain "Checkers". The result is the total revenue from checkers. 2. Formula entered in the D3 cell is =DSUM(B1:C6, "Revenue", B8:B9). The function sums the values from the Revenue column if the corresponding cells in the Supplier column contain 3-character strings ending with -m. The result is the total revenue from Tom and Sam. 3. Formula entered in the D4 cell is =DSUM(A1:C6, 3, C8:C9). The function sums values from the third column if they are larger than or equal to 400. The result is the combined revenue from checkers sold by Sam and puzzles sold by Peter. 4. Formula entered in the D5 cell is =DSUM(A1:C6, "Revenue", A8:A10). The function sums the values in the Revenue column if the corresponding cells in the Product column contain "Checkers" or a string that starts with letter P. The result is the total revenue from checkers and puzzles. 5. Formula entered in the D6 cell is =DSUM(A1:B6, 2, A8:A9). The second column contains only strings. As a result, the function ignores all the values in it and returns 0. 179 6. Formula entered in the D7 cell is =DSUM(A1:C6, 3, A8:C10). The function sums the values from the third column if the corresponding cells match conditions specified either in the second or in the third row of criteria. The result is the combined revenue from puzzles sold by Tom and checkers sold by Sam. 180 Chapter 8 Logical functions 181 AND Returns TRUE if all of the supplied tests are successful, and FALSE if at least one fails. Syntax =AND(logical_expression1, [logical_expression2, ...]) logical_expression1 — a logical test or expression, a reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE. [logical_expression2, ...] (optional) — additional logical tests or expressions, references to cells containing expressions that represent some logical values, i.e. TRUE or FALSE. Notes • AND evaluates 0 to FALSE; negative and positive numbers – to TRUE. • AND supports numbers presented as strings, e.g. "12", and evaluates them to TRUE. • AND ignores non-numeric values which may be in the range considered in the calculation. • If all arguments contain or refer to text values, AND returns the #VALUE! error. • The maximum number of the logical_expression arguments is limited to 255. Examples 1 A B Data Result 2 C D E -55 TRUE 3 value #VALUE! 4 FALSE TRUE 5 n/a FALSE 6 TRUE FALSE 7 1. Formula entered in the B2 cell is =AND("89", "-41"). As a result, the function returns TRUE because numbers presented as strings are evaluated to TRUE. 182 2. Formula entered in the B3 cell is =AND(A3, "link"). As a result, the function returns the #VALUE! error as both values are text. 3. Formula entered in the B4 cell is =AND(A3>0, A4=FALSE). As a result, the function returns TRUE as both logical tests are logically true. 4. Formula entered in the B5 cell is =AND(A5<-13). As a result, the function returns FALSE as the value in A5 is less than -13. 5. Formula entered in the B6 cell is =AND(A2:A6). As a result, the function returns FALSE as some values in the range are logically false. 183 FALSE Returns the FALSE logical value. Syntax =FALSE() Notes • The application automatically converts the FALSE literal to the FALSE logical value (case-sensitive). Examples A B C 1 Data Result 2 FALSE 3 1 FALSE D E 4 1. Formula entered in the B2 cell is =FALSE(). As a result, the function returns the FALSE logical value. 2. Formula entered in the B3 cell is =IF(A3<10, FALSE()). As a result, the function returns FALSE because the first logical test is TRUE, and the second test is FALSE. The IF function results in TRUE if both conditions are met. 184 IF Returns one value if the result of a logical test is TRUE and another if it is FALSE. Syntax =IF(logical_expression, value_if_true, [value_if_false]) logical_expression — a logical test, expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE. value_if_true — a value to return if logical_expression is TRUE. [value_if_false] (optional) — a value to return if logical_expression is FALSE. If the argument is omitted, FALSE is set by default. Notes • Uppercase and lowercase text values are considered as equivalent. Examples A B 1 Data Result 2 N/A 3 4 5 C D E OK Failed test 72 No way! 7 6 1. Formula entered in the B2 cell is =IF(A2="n/a", "OK"). As a result, the function evaluates the test to TRUE as cell A2 contains the "n/a" value. 2. Formula entered in the B3 cell is =IF(5=2+2, "Successful test", "Failed test"). As a result, the function evaluates the test to FALSE as 5 is not equal to 2+2. 3. Formula entered in the B4 cell is =IF(A4<56, "Well done!", "No way!"). As a result, the function evaluates the test to FALSE as the number in cell B4 is greater 185 than 56. 4. Formula entered in the B5 cell is =IF(TRUE, 7, 9). As a result, the function returns the value that corresponds to the TRUE logical test. 186 IFERROR Returns the first argument if it is not an error value, and the second argument if a given value is an error. Syntax =IFERROR(value, value_if_error) value — a value to return if value itself is not an error. value_if_error — a value to return if value is an error. Examples 1 A B C Data Result 2 25 3 #VALUE! error value 4 TRUE D E TRUE 5 1. Formula entered in the B2 cell is =IFERROR("25", "number"). As a result, the function returns the supplied value as it is not an error value. 2. Formula entered in the B3 cell is =IFERROR(A3, "error value"). As a result, the function returns the value specified in the second argument as cell A3 contains an error value. 3. Formula entered in the B4 cell is =IFERROR(A4, "logical value"). As a result, the function returns the value specified in the first argument as cell A4 does not contain an error value. 187 IFNA Returns the first argument if it is not #N/A, otherwise, returns the second argument. Syntax =IFNA(value, value_if_na) value — a value to be checked as the #N/A error. value_if_na — a value to be returned if value is the #N/A error. Examples A B 1 Data Result 2 12 3 4 C D E 12 #N/A Not available No match 5 1. Formula entered in the B2 cell is =IFNA(A2, "Unspecified"). As a result, the function returns the value specified in cell A2 as it does not contain the #N/A error. 2. Formula entered in the B3 cell is =IFNA(A3, "Not available"). As a result, the function returns the value specified in the second argument as cell A3 contains the #N/A error. 3. Formula entered in the B4 cell is =IFNA(MATCH("row", A2:A4, A2), "No match"). As a result, the function checks whether the MATCH function results in #N/A and, as so, returns "No match". 188 OR Returns TRUE if any of the specified logical tests is successful, and FALSE if all logical tests fail. Syntax =OR(logical_expression1, [logical_expression2, ...]) logical_expression1 — a logical test or expression, a reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE. [logical_expression2, ...] (optional) — additional logical tests or expressions, references to cells containing expressions representing some logical values, i.e. TRUE or FALSE. Notes • OR evaluates 0 to FALSE; negative and positive numbers – to TRUE. • OR supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. • The maximum number of the function arguments is limited to 255. Examples 1 2 A B C Data Result E FALSE TRUE 3 -13 FALSE 4 0 FALSE 5 D value TRUE 6 1. Formula entered in the B2 cell is as follows =OR("12", "-3"). As a result, the function checks whether the numbers are logically true or false ("12" and "-3" presented as a string are casted to 12 and -3, respectively). 2. Formula entered in the B3 cell is as follows =OR(A3>0, A2=TRUE). As a result, the function checks whether at least one logical test is true. 189 3. Formula entered in the B4 cell is as follows =OR(A4). As a result, the function checks the entry in cell A4 and returns the logical value that corresponds to 0. 4. Formula entered in the B5 cell is as follows =OR(A5>0). As a result, the function checks whether the value in cell A5 is greater (TRUE) or less (FALSE) than 0. 190 SWITCH Evaluates a list of expressions and returns a value corresponding to the first expression in the list. Syntax =SWITCH(expression, [default]) value1, result1, [value2, result2, ...], expression — a value to be compared against value1, ... valueN. value1 — a value to be compared against expression. result1 — a value to be returned if valueN matches expression. [value2, result2, ...] (optional) — additional pairs of the value and result arguments to consider. [default] (optional) — a value which is to be returned if no match is found. Notes • If the default argument is not set, SWITCH returns the #N/A error when no match is found. • If a list of expressions contains more than one match, SWITCH returns the first matching value. • The maximum number of the function arguments is limited to 254. Examples 1 A B C Data Result 2 45 Mary 3 67 No match 4 34 #N/A 5 12 Linda D E 6 1. Formula entered in the B2 cell is =SWITCH(45, 45, "Mary"). As a result, the function returns the value corresponding to 45, that is equal to "Mary". 191 2. Formula entered in the B3 cell is =SWITCH(A3, 34, "Kate", 61, "Danny", "No match"). As a result, the function returns the default value as no matching value is found. 3. Formula entered in the B4 cell is =SWITCH(A4, 67, "Tom", 45, "Mary"). As a result, the function returns the #N/A error as there is no value corresponding to 34 (cell A4 contains 34) in the list, and the default value is not specified. 4. Formula entered in the B5 cell is =SWITCH(A5, 67, "Tom", 12, "Linda", 12, "Garry"). As a result, the function returns the first matching value that corresponds to 12 (cell A5 contains 12). 192 TRUE Returns the TRUE logical value. Syntax =TRUE() Notes • The application automatically converts the TRUE literal to the TRUE logical value (case-sensitive). Examples A 1 B C D E Data Result 2 TRUE 3 5 TRUE 4 1. Formula entered in the B2 cell is =TRUE(). As a result, the function returns the TRUE logical value. 2. Formula entered in the B3 cell is =OR(A3<10). As a result, the function returns TRUE because logical test is successful. 193 Chapter 9 Date and time functions 194 DATE Composes a date based on the supplied values of day, month and year. Syntax =DATE(year, month, day) year — a number representing a year component in a date. month — a number representing a month component in a date. day — a number representing a day component in a date. Notes • DATE supports dates from 1/1/0001 to 12/31/9999. If an input value goes beyond the limits, the function returns the #NUM! error. • DATE supports numbers presented as strings, e.g. "12". • If an entry is not a number, DATE returns the #VALUE error. • If an entry is a decimal number, DATE truncates its fractional part. • If month is less than 1 or greater than 12, DATE recalculates the supplied values and returns the result in the correct date format. See examples #2 and #3 for more details. • If day is less than 1 or greater than the number of days in month, DATE recalculates the supplied values and returns the result in the correct date format. See examples #4 and #5 for more details. 195 Examples 1 A B C Data Result 2 1/10/2001 3 2/12/2002 4 9/2/1996 5 8/30/2016 6 7/4/1882 7 6/17/2012 8 #NUM! 9 D E 5/9/2008 10 1. Formula entered in the B2 cell is =DATE(2001, 1, 10). The function converts the supplied values into a date and returns 1/10/2001. 2. Formula entered in the B3 cell is =DATE(2001, 14, 12). The month value is greater than 12. As a result, the function adds 14 months to the supplied year, i.e. 2001, and returns 2/12/2002. 3. Formula entered in the B4 cell is =DATE(1997, -3, 2). The month value is less than 1. As a result, the function subtracts 3 months from the supplied year, i.e. 1997, and returns 9/2/1996. 4. Formula entered in the B5 cell is =DATE(2016, 9, -1). The day value is less than 1. As a result, the function subtracts 1 day from the supplied month, i.e. September, and returns 8/30/2016. 5. Formula entered in the B6 cell is =DATE(1882, 6, 34). The day value is more than the number of days in June. As a result, the function adds 34 days to the supplied month, i.e. June, and returns 7/4/1882. 6. Formula entered in the B7 cell is =DATE("2012", "6", "17"). The function casts strings into integers and converts them into a date, which is 6/17/2012. 7. Formula entered in the B8 cell is =DATE(-1224, 7, 9). The function returns the 196 #NUM! error because the supplied year is outside the supported date range of the editor (1/1/0001 – 12/31/9999). 8. Formula entered in the B9 cell is =DATE(2008, 5.3, 9.6). The function truncates fractional numbers to integers and converts the received entries into a date, which is 5/9/2008. 197 DATEVALUE Transforms a supplied date string in a known format to a numeric date value. Syntax =DATEVALUE(date_string) date_string — a date presented as a string. Notes • The application stores dates as numeric date values beginning with December 30, 1899 ("zero" date). A numeric date value indicates the number of days that has passed since the "zero" date. • The date formulas support dates from 1/1/0001 to 12/31/9999. In case an input value goes beyond the limits, DATEVALUE returns the #NUM! error. • Date and time formats may vary depending on the regional preferences set on your workstation. • To ensure the date_string value is entered correctly, use the DATE function. Examples 1 A B Data Result 2 3 6 D E 40692 3/22/2011 4 5 C 40624 32210 14-Feb-80 65790 39816 7 1. Formula entered in the B2 cell is =DATEVALUE("05-29-2011"). As a result, the function transforms the supplied date string to its numeric value, that is equal to 40692. 198 2. Formula entered in the B3 cell is =DATEVALUE(A3). As a result, the function transforms the date string in cell A3 to its numeric value, that is equal to 40624. 3. Formula entered in the B4 cell is =DATEVALUE("8 March 1988"). As a result, the function transforms the supplied date string to its numeric value, that is equal to 32210. 4. Formula entered in the B5 cell is =DATEVALUE(A5). As a result, the function transforms the date string in cell A5 to its numeric value, that is equal to 65790. 5. Formula entered in the B6 cell is =DATEVALUE(DATE(2009, 1, 3)). As a result, the function transforms 1/3/2009 to its numeric value, that is equal to 39816. 199 DAY Retrieves a day component from a given date. Syntax =DAY(date) date — a date from which to retrieve a day component. Notes • To ensure the date value is entered correctly, use the DATE function or make a reference to a cell containing a date or a function returning a date type. Examples 1 A B Data Result 2 3 4 C D E 6 2/10/1990 10 25 5 1. Formula entered in the B2 cell is =DAY(DATE(2003, 8, 6)). As a result, the function returns a day of the supplied date. 2. Formula entered in the B3 cell is =DAY(A3). As a result, the function returns a day of the date in cell A3. 3. Formula entered in the B4 cell is =DAY(TODAY()). As a result, the function returns a day of the current date. The result may vary based on the current date. 200 EDATE Returns a numeric value of a date which falls a specified number of months before or after another date. Syntax =EDATE(start_date, months) start_date — the initial date from which to count months. months — the number of months to be subtracted from (negative value) or added to (positive value) start_date. Notes • To ensure the start_date value is entered correctly, use the DATE function or make a reference to a cell containing a date or a function returning a date type. • If months is specified as a non-integer, its fractional part is truncated. • If the start_date argument is entered directly to the formula, it must be presented as a string, e.g. "1/10/2017". • The application stores dates as numeric date values beginning with December 30, 1899 ("zero" date). A numeric date value indicates the number of days that has passed since the "zero" date. • The date formulas support dates from 1/1/0001 to 12/31/9999. In case an input date value goes beyond the limits, EDATE returns the #VALUE! error. • Date and time formats may vary depending on the regional preferences set on your computer. 201 Examples A B 1 Data Result 2 4/18/2002 37425 3 42821 4 33368 5 -8347 C D E 6 1. Formula entered in the B2 cell is as follows =EDATE(A2, 2). As a result, the function checks for the date that falls 2 months after the date specified in cell A2, that is 6/18/2002, and returns its numeric value. 2. Formula entered in the B3 cell is as follows =EDATE(NOW(), -3). As a result, the function subtracts 3 months from the current date, 6/27/2017, and returns a numeric value for 3/27/2017. The result varies based on the current date. 3. Formula entered in the B4 cell is as follows =EDATE("10-Jan-1991", 4). As a result, the function checks for the date that falls 4 months after the supplied date, that is 5/10/1991, and returns its numeric value. 4. Formula entered in the B5 cell is as follows =EDATE(DATE(1877, 4, 21), -2). As a result, the function checks for the date that falls 2 months before the supplied date, that is 2/21/1877, and returns its numeric value. 202 EOMONTH Returns a numeric date value which corresponds to the last calendar day of the month based on the initial date and the number of months before or after it. Syntax =EOMONTH(start_date, months) start_date — the initial date from which to count months. months — the number of months to be subtracted from (negative value) or added to (positive value) start_date. Notes • The date formulas support dates from 1/1/0001 to 12/31/9999. In case an input date value goes beyond the limits, EOMONTH returns the #VALUE! error. • EOMONTH considers only integers in the calculation and removes fractional parts of numbers supplied to the formula. • To ensure the start_date input is entered correctly, use the DATE function or make a reference to a cell containing a date or a function returning a date type. Examples 1 A B Data Result 2 3 C D E 40512 11/01/99 36556 4 1. Formula entered in the B2 cell is =EOMONTH(DATE(2011, 2, 12), -3). As a result, the function checks for the month that falls 3 months before the supplied date, that is November, and returns a numeric date value of the last calendar day of November. 2. Formula entered in the B3 cell is =EOMONTH(A3, 2). As a result, the function checks for the month that falls 2 months after the date in cell A3, that is January, and returns a numeric date value of the last calendar day of January. 203 HOUR Extracts an hour component from a given time value. Syntax =HOUR(time) time — a time value from which to extract an hour component. It can be a reference to a cell containing a time value or a result of another function returning a time value. Notes • If the time argument is entered directly to the formula, it must be presented as a string, e.g. "12:35 PM". • Date and time formats may vary depending on the regional preferences set on your computer. Examples A B C 1 Data Result 2 10:37:00 AM D E 10 3 17 4 19 5 12 6 0 7 1. Formula entered in the B2 cell is as follows =HOUR(A2). As a result, the function extracts an hour component of the time in cell A2 and returns 10. 2. Formula entered in the B3 cell is as follows =HOUR("17:21"). As a result, the function extracts an hour component of the specified time and returns 17. 3. Formula entered in the B4 cell is as follows =HOUR(NOW()). As a result, the function extracts an hour component of the current time, 19:08:07 PM. The result varies based on the current time. 204 4. Formula entered in the B5 cell is as follows =HOUR(TIME(12, 34, 50)). As a result, the function returns 12 as TIME represents 12:34:50 PM. 5. Formula entered in the B6 cell is as follows =HOUR("24:00"). As a result, the function returns 0 as the specified time is equivalent to 00:24:00. 205 ISOWEEKNUM Returns the ISO week number (from 1 to 54) for a given date. Syntax =ISOWEEKNUM(date) date — a date for which the ISO week number is to be returned. It can be a reference to a cell containing a date or a result of another function returning a date. Notes • The ISOWEEKNUM function returns a week number based on the ISO-8601 standard. Under this standard, weeks begin on Monday, and week 1 is assigned to the first week in a year that contains Thursday. • To ensure the date value is entered correctly, it is recommended to use the DATE function. • If the date value is entered directly to the formula, it must be presented as a string, e.g. "1/10/2017". • Date and time formats may vary depending on the regional preferences set on your computer. Examples A B C 1 Data Result 2 4/23/1997 D E 17 3 5 4 26 5 16 6 1. Formula entered in the B2 cell is =ISOWEEKNUM(A2). As a result, the function returns the ISO week number for the date in cell A2, that is equal to 17. 206 2. Formula entered in the B3 cell is =ISOWEEKNUM("Jan-31-2011"). As a result, the function returns the ISO week number for the supplied date, that is equal to 5. 3. Formula entered in the B4 cell is =ISOWEEKNUM(TODAY()). As a result, the function returns the ISO week number for the current date, 6/27/2017, that is equal to 26. The result may vary based on the current date. 4. Formula entered in the B5 cell is =ISOWEEKNUM(DATE(2010, 4, 25)). As a result, the function returns the ISO week number for 4/25/2010, that is equal to 16. 207 MINUTE Extracts a minute component from a given time value. Syntax =MINUTE(time) time — a time value from which to extract minutes. It can be a reference to a cell containing a time value or a result of another function returning a time value. Notes • If the time argument is entered directly to the formula, it must be presented as a string, e.g. "12:35 PM". • Date and time formats may vary depending on the regional preferences set on your computer. Examples A B C 1 Data Result 2 9:25:00 AM D E 25 3 45 4 18 5 12 6 1. Formula entered in the B2 cell is as follows =MINUTE(A2). As a result, the function extracts the minutes from the time in cell A2 and returns 25. 2. Formula entered in the B3 cell is as follows =MINUTE("12:45"). As a result, the function extracts the minutes from the supplied time and returns 45. 3. Formula entered in the B4 cell is as follows =MINUTE(NOW()). As a result, the function extracts the minutes from the current time, 5:18:07 PM. The result varies based on the current time. 208 4. Formula entered in the B5 cell is as follows =MINUTE(TIME(16, 12, 56)). As a result, the function returns 12 as TIME represents 4:12:56 PM. 209 MONTH Extracts a month from a given date. The result is displayed in numeric format. Syntax =MONTH(date) date — a date from which to extract a month. Notes • To ensure the entered date is in the correct format, use the DATE function or make a reference to a cell containing a date or a function returning a date type. • Date and time formats vary depending on the regional preferences set on your workstation. For example, for the US region, the date components sequence appears as mm/dd/yy. Examples 1 A B Data Result 2 3 4 C D E 3 5/12/2000 5 7 5 1. Formula entered in the B2 cell is as follows =MONTH(DATE(1994, 3, 9)). As a result, the function returns the month of the supplied date. 2. Formula entered in the B3 cell is as follows =MONTH(A3). As a result, the function returns the month of the date in cell A3. 3. Formula entered in the B4 cell is as follows =MONTH("08 Jul 2016"). As a result, the function returns the month of the date in the supplied date. 210 NOW Returns the current date and time as a timestamp value. Syntax =NOW() Notes • NOW allows returning the date and time that come a certain number of days/hours before (negative) or after (positive) the current date and time. Digits to the left of the decimal point represent the number of days; digits to the right specify the time value (0.5 stands for 12 hours). For example, enter =NOW()-1 to return the yesterday’s date. Examples 1 A B C Data Result 2 1/10/2017 1:42:10 PM 3 1/10/2017 7:42:10 AM 4 1/12/2017 1:42:10 AM D E 5 1. Formula entered in the B2 cell is as follows =NOW(). As a result, the function returns the current date and time. The result varies based on the current date and time. 2. Formula entered in the B3 cell is as follows =NOW()-0.25. As a result, the function subtracts 6 hours from the current time. The result varies based on the current date and time. 3. Formula entered in the B4 cell is as follows =NOW()+1.5. As a result, the function adds 1 day and 12 hours to the current date and time. The result varies based on the current date and time. 211 TODAY Returns the current date. Syntax =TODAY() Notes • TODAY allows returning the date that comes a certain number of days before (negative) or after (positive) the current date. For example, enter =TODAY()-1 to return the yesterday’s date. Examples 1 A B C Data Result 2 2/23/2017 3 2/20/2017 4 2/27/2017 5 23 6 2 7 17 D E 8 1. Formula entered in the B2 cell is as follows =TODAY(). As a result, the function returns the current date. The result varies based on the current date. 2. Formula entered in the B3 cell is as follows =TODAY()-3. As a result, the function returns the date that came 3 days before the current date. The result varies based on the current date. 3. Formula entered in the B4 cell is as follows =TODAY()+4. As a result, the function returns the date of the day that will come in 4 days. The result varies based on the current date. 212 4. Formula entered in the B5 cell is as follows =DAY(TODAY()). As a result, the function returns the day of the current date. The result varies based on the current date. 5. Formula entered in the B6 cell is as follows =MONTH(TODAY()). As a result, the function returns the month of the current date. The result varies based on the current date. 6. Formula entered in the B7 cell is as follows =YEAR(TODAY()). As a result, the function returns the year of the current date. The result varies based on the current date. 213 YEAR Retrieves a year component from a given date. Syntax =YEAR(date) date — a date from which to retrieve a year component. Notes • To ensure the entered date is in the correct format, use the DATE function or make a reference to a cell containing a date or a function returning a date type. • The Editor supports dates from 1/1/0001 to 12/31/9999. In case an input value goes beyond the limits, YEAR returns the #VALUE! error. Examples 1 A B Data Result 2 3 4 C D E 2011 8/12/1999 1999 #VALUE! 5 1. Formula entered in the B2 cell is as follows =YEAR(DATE(2011, 10, 10)). As a result, the function returns the year of the supplied date. 2. Formula entered in the B3 cell is as follows =YEAR(A3). As a result, the function returns the year of the date in cell A3. 3. Formula entered in the B4 cell is as follows =YEAR("5/31/10000"). As a result, the function returns the #VALUE! error as the supplied date is beyond the limit value. 214 Chapter 10 Statistical functions 215 AVERAGE Returns the average of numbers in a dataset. Syntax =AVERAGE(value1, [value2, ...]) value1 — the first number or range of cells containing numbers to consider. [value2, ...] (optional) — additional numbers or ranges of cells. Notes • AVERAGE ignores non-numeric values and empty cells which may be in a range or an array. • If all arguments are non-numeric, AVERAGE returns the #DIV/0! error value. • AVERAGE supports numbers presented as strings, e.g. "12". The resulted value is recognized as a number. • The maximum number of the function arguments is limited to 255. Examples A 1 B C D E Data Result 2 48 6 3 value 3 4 66 40.5 5 15 43 6 1. Formula entered in the B2 cell is =AVERAGE("7", "5"). As a result, the function returns the average of 7 and 5 ("7" and "5" are casted to 7 and 5, respectively). 2. Formula entered in the B3 cell is =AVERAGE({3, 5, 6}, {-7, 5, 6}). As a result, the function returns the average of numbers in the arrays of numbers, that is equal to 3. 216 3. Formula entered in the B4 cell is =AVERAGE(A4, A5). As a result, the function returns the average of values stored in separate cells A4 and A5, that is equal to 40.5. 4. Formula entered in the B5 cell is =AVERAGE(A2:A5). As a result, the function returns the average of values in the A2:A5 range, that is equal to 43. 217 COUNT Returns the count of numeric values in a supplied dataset. Syntax =COUNT(value1, [value2, ...]) value1 — the first value, array, range, or cell reference to consider. [value2, ...] (optional) — additional values, arrays, ranges, or cell references. Notes • In addition to numbers, COUNT considers also all formatted numeric values such as date, time, percentage and currency values. • COUNT supports numbers presented as strings, e.g. "12". The resulted value is recognized as a number. • Logical values are counted if they are supplied directly to the list of arguments. • COUNT ignores non-numeric values that may be in the range considered in the calculation. • The maximum number of the function arguments is limited to 255. Examples 1 A B C Data Result 2 13 2 3 67 2 4 TRUE D E 3 5 92 5 6 01/01/1990 3 7 1. Formula entered in the B2 cell is =COUNT("25", "19"). As a result, the function returns the count of 25 and 19 ("25" and "19" are casted to 25 and 19, respectively). 218 2. Formula entered in the B3 cell is =COUNT(TRUE, A3). As a result, the function returns the count of values, including a logical value, that is equal to 2. 3. Formula entered in the B4 cell is =COUNT(A2, A3, A5). As a result, the function returns the count of numbers in cells A2, A3, A5, that is equal to 3. 4. Formula entered in the B5 cell is =COUNT(A2:A6, 1). As a result, the function returns the count of numbers and dates in the dataset, that is equal to 5. 5. Formula entered in the B6 cell is =COUNT(A2:A5). As a result, the function returns the count of numeric values in the A2:A5 range, that is equal to 3. 219 COUNTA Looks through a given dataset and returns the number of cells containing any type of information. Syntax =COUNTA(value1, [value2, ...]) value1 — the first value, array, range, or cell reference to consider. [value2, ...] (optional) — additional values, arrays, ranges, or cell references. Notes • COUNTA ignores empty cells but counts cells with white spaces (" "). • COUNTA counts empty strings supplied directly to the function arguments. • The maximum number of the function arguments is limited to 255. Examples A B C 1 Data Result 2 3 3 4 5 25 - D E 3 2 89 3 6 1. Formula entered in the B2 cell is =COUNTA(" ", "amount", 34). As a result, the function returns the count of values supplied directly to the function arguments. 2. Formula entered in the B3 cell is =COUNTA("price", A2:A4). As a result, the function returns the count of values in the supplied dataset. 3. Formula entered in the B4 cell is =COUNTA(A3, A4). As a result, the function returns the count of filled cells in the supplied dataset. 220 4. Formula entered in the B5 cell is =COUNTA(A2:A5). As a result, the function returns the count of filled cells in the A2:A5 range. 221 COUNTBLANK Returns the count of empty and blank cells in a given range or array. Syntax =COUNTBLANK(range) range — an array or a range in which to count the number of empty and blank cells. Notes • If a cell contains a formula resulted in an empty string (""), the cell is counted. • For more information on the difference between empty and blank values, refer to the Empty chapter in the Formula structure article. Examples 1 A B Data Result 2 3 4 C D E #VALUE! 14 2 3 5 1. Formula entered in the B2 cell is =COUNTBLANK(56). As a result, the function returns the #VALUE! error as the argument must contain a range of cells, but it does not. 2. Formula entered in the B3 cell is =COUNTBLANK(A2:A4). As a result, the function returns the number of empty cells in the A2:A4 range, that is equal to 2. 3. Formula entered in the B4 cell is =COUNTBLANK({"", , ""}). As a result, the function returns the number of empty and blank values in the array, that is equal to 3. 222 COUNTIF Returns the number of times cell values meet a certain criterion. Syntax =COUNTIF(range, criterion) range — a range to be checked against criterion. criterion — a condition to be applied to range. Notes • Text criteria, criteria containing mathematical symbols, and wildcard characters must be enclosed in double quotation marks, e.g. "value". • Uppercase and lowercase text values are considered as equivalent. • Wildcard characters enable you to filter a list of data based on a supplied condition and count values by partial match. • Several mathematical symbols specified as a part of a criterion must be entered without spaces, e.g. "<= 40". • COUNTIF allows specifying multiple conditions to be applied to a single range. To do this, enter the conditions as an array, e.g. {1,2,3}. Examples A 1 Data B C D E Sales Sales Dates Result 2 Cards 4 01/01/2008 2 3 Draughts 5 01/04/2009 5 4 Darts 8 01/04/2009 3 5 Draughts 2 06/01/2008 2 6 Puzzles 10 01/01/2008 2 7 Billiard 1 05/12/2008 3 8 1. Formula entered in the D2 cell is =COUNTIF(A2:A7, "Draughts"). As a result, 223 the function returns the count of cells containing the "Draughts" text values in the A2:A7 range. 2. Formula entered in the D3 cell is =COUNTIF(A2:A7, "*s"). As a result, the function returns the number of text values ending with -s in the A2:A7 range. 3. Formula entered in the D4 cell is =COUNTIF(B2:B7, ">=5"). As a result, the function returns the count of values greater than or equal to 5 in the B2:B7 range. 4. Formula entered in the D5 cell is =COUNTIF(A2:A7, "????s"). As a result, the function returns the count of cells containing 5-character long values that end with -s in the A2:A7 range. 5. Formula entered in the D6 cell is =COUNTIF(C2:C7, DATE(2008,1,1)). As a result, the function returns the count of cells containing the specified date in the C2:C7 range. 6. Formula entered in the D7 cell is =SUM(COUNTIF(B2:B7, {4,2,5})). The COUNTIF function counts the number of cells matching the specified conditions and SUM sums up the result of count. 224 COUNTIFS Returns the number of cells that meet multiple criteria. Syntax =COUNTIFS(criteria_range1, criterion1, [criteria_range2, criterion2, ...]) criteria_range1 — a range to be tested against criterion1. criterion1 — a condition to be applied to criteria_range1. [criteria_range2, criterion2, ...] (optional) — additional ranges and conditions. Notes • Text criteria, criteria containing mathematical symbols, and wildcard characters must be enclosed in double quotation marks, e.g. "value". • Uppercase and lowercase text values are considered as equivalent. • Wildcard characters enable you to filter a list of data based on a supplied condition and count values by partial match. • Several mathematical symbols specified as a part of a criterion must be entered without spaces, e.g. "<= 40". • Ranges or arrays involved in the calculation must be equal in size. Otherwise, COUNTIFS returns the #VALUE! error. • The number of the criteria_range values must equal the number of criterion values. Otherwise, the function returns the #VALUE! error. • COUNTIFS allows specifying multiple conditions to be applied to a single range. To do this, enter the conditions as an array, e.g. {1,2,3}. • The maximum number of the function arguments is limited to 254. 225 Examples A B C D E 1 Data Sales Sales Dates Result 2 Oranges 71 01/01/2008 1 3 Bananas 32 01/04/2009 4 4 Mangoes 69 01/04/2009 2 5 Grapefruits 65 01/01/2008 2 6 Apples 45 01/07/2009 2 7 1. Formula entered in the D2 cell is =COUNTIFS(A2:A6,"mangoes", C2:C6, DATE(2009, 1, 4)). As a result, the function returns the count of cells containing the "Mangoes" values in the A2:A6 range and their sales on 01/04/2009 (C2:C6). 2. Formula entered in the D3 cell is =COUNTIFS(A2:A6, "*s", B2:B6, "<70"). As a result, the function evaluates the A2:A6 range for the text values ending with -s and returns their count if the values in the B2:B6 range are less than 70. 3. Formula entered in the D4 cell is =COUNTIFS(A2:A6, "??????s", B2:B6, ">=40"). As a result, the function checks the A2:A6 range for 7-character long values and the B2:B6 range for their sales amounts that are greater than or equal to 40 and returns the count of their occurrences. 4. Formula entered in the D5 cell is =COUNTIFS(A2:A6, "*s", C2:C6, "<01/04/2009"). As a result, the function returns the count of rows meeting both conditions: values ending with -s in the A2:A6 range and sales made before 01/04/2009 (C2:C6). 5. Formula entered in the D6 cell is =SUM(COUNTIFS(A2:A6, {"Oranges", "Mangoes"}, B2:B6, {71, 61})). The function counts the number of rows meeting the following conditions: the amount of oranges’ sales is 71 and the amount of mangoes’ sales is 69. As both conditions are met, SUM sums up the result of count. 226 F.DIST.RT Calculates the right-tailed F probability distribution (degree of diversity) for two data sets. Syntax =F.DIST.RT(x, freedom_degrees1, freedom_degrees2) x — a value for which the distribution is to be calculated. freedom_degrees1 — numerator degrees of freedom. freedom_degrees2 — denominator degrees of freedom. Notes • The FDIST and F.DIST.RT functions are identical. When entering FDIST, it is automatically replaced with F.DIST.RT. • If x is negative, F.DIST.RT returns the #NUM! error. • If any of the arguments are non-numeric, F.DIST.RT returns the #VALUE! error. However, logical values and text representations of numbers you specify as arguments are allowed, they are considered as valid. • If either freedom_degrees1 or freedom_degrees2 is less than 1, F.DIST.RT returns the #NUM! error. • If a decimal value is provided to freedom_degrees1 or freedom_degrees2, its decimal part is truncated. • The maximum number of the freedom_degrees arguments is limited to 10000000000 (10^10). Examples A B 1 Data Result 2 10.97 0.841761297 3 4 C 2 #NUM! 23 0.000451429 5 227 D E 1. Formula entered in the B2 cell is =F.DIST.RT(2/4,9,9). As a result, the function returns the F probability distribution meaning that there is roughly an 84% probability that an F value as large as if the samples variances were equivalent. 2. Formula entered in the B3 cell is =F.DIST.RT(-5,3,2). As a result, the function returns the #NUM! error as x is negative. 3. Formula entered in the B4 cell is =F.DIST.RT(A2,A3,A4). As a result, the function calculates the F probability distribution based on the supplied terms: data entered in cell A2 – a value at which to evaluate the function; data entered in cell A3 – numerator degrees of freedom; data entered in cell A4 – denominator degrees of freedom. 228 F.DIST Calculates the left-tailed F probability distribution (degree of diversity) for two datasets. Syntax =F.DIST(x, freedom_degrees1, freedom_degrees2, cumulative) x — a value for which the distribution is to be calculated. freedom_degrees1 — numerator degrees of freedom. freedom_degrees2 — denominator degrees of freedom. cumulative — a logical expression that specifies whether to return the normal cumulative distribution (TRUE) or probability density (FALSE) function. Notes • If x is negative, F.DIST returns the #NUM! error. • If either freedom_degrees1 or freedom_degrees2 is less than 1, F.DIST returns the #NUM! error. • If any of the arguments are non-numeric, F.DIST returns the #VALUE! error. • If a decimal value is provided to freedom_degrees1 or freedom_degrees2, the decimal part is truncated. Examples A B C 1 Data Result 2 20.76 0.029252692 3 8 #NUM! 4 3 0.001043223 5 0.984979066 D E 6 1. Formula entered in the B2 cell is =F.DIST(5, 3, 2, FALSE). As a result, the function calculates the F probability distribution based on the following terms: 5 – an input to the F probability distribution function; 3 – numerator degrees of freedom; 229 2 – denominator degrees of freedom. The function returns the probability density function. 2. Formula entered in the B3 cell is =F.DIST(5, 3, -2, TRUE). As a result, the function returns the #NUM! error as an argument is a negative value. 3. Formula entered in the B4 cell is =F.DIST(A2, A3, A4, FALSE). As a result, the function calculates the F probability distribution based on the supplied terms: A2 – an input to the F probability distribution function; A3 – numerator degrees of freedom; A4 – denominator degrees of freedom. The function returns the probability density function. 4. Formula entered in the B5 cell is =F.DIST(A2, A3, A4, TRUE). As a result, the function calculates the F probability distribution based on the supplied terms: A2 – an input to the F probability distribution function; A3 – numerator degrees of freedom; A4 – denominator degrees of freedom. The function returns the normal cumulative distribution. 230 FISHER Returns the Fisher transformation for a given value. The function is frequently used to test hypotheses on the correlation coefficient. Syntax =FISHER(value) value — a number (from -1 to 1, exclusive) for which to calculate the Fisher transformation. Notes • FISHER supports numbers presented as strings, e.g. "0.1". The resulted value is recognized as a number. • If the supplied number is beyond the preset limits, the #NUM! error is displayed. • If value is non-numeric, FISHER returns the #VALUE! error. • If value is a reference with an empty value, it is casted to 0 (zero). Examples 1 2 A B C Data Result D E 0.100335348 3 #NUM! 4 -0.99 -2.646652412 5 0 6 1. Formula entered in the B2 cell is =FISHER(0.1). As a result, the function returns the Fisher transformation for 0.1, that is equal to 0.100335348. 2. Formula entered in the B3 cell is =FISHER(2.3). As a result, the function returns the #NUM! error as the supplied value exceeds the permitted upper limit. 231 3. Formula entered in the B4 cell is =FISHER(A4). As a result, the function returns the Fisher transformation for the value in cell A4, that is equal to -2.646652412. 4. Formula entered in the B5 cell is =FISHER(A5). An empty value in cell A5 is casted to 0. Thus, the function returns the Fisher transformation for 0, that is equal to 0. 232 LARGE Arranges a given numeric dataset in descending order and returns a value depending on its relative position where the largest value takes the first position. Syntax =LARGE(data, n) data — an array or a range of cells containing a numeric dataset to consider. n — a number position in the rank from largest to smallest. Notes • LARGE ignores non-numeric values that may be in a range or an array. • The n value must be greater than or equal to 1. Otherwise, LARGE returns the #NUM! error value. • LARGE supports numbers presented as strings, e.g. "12". The resulted value is recognized as a number. • LARGE covers both sorted and/or unsorted ranges or arrays. Examples 1 A B ID Data C D E Price Result 2 1 Apple 25 15 3 2 Banana 43 13 4 3 Grapefruit 89 55 5 4 Mango 87 #NUM! 6 5 Orange 55 5 7 1. Formula entered in the D2 cell is =LARGE({"15", "29", "31"}, 3). As a result, the function returns the 3rd largest value from the array of numbers 15, 29, 31 ("15", "29", "31" are casted to 15, 29, 31, respectively). 233 2. Formula entered in the D3 cell is =LARGE({10, 13, 15}, 2). As a result, the function retrieves the 2nd largest value from the supplied array. 3. Formula entered in the D4 cell is =LARGE(C2:C6, 3). As a result, the function retrieves the 3rd largest value from the unsorted range. 4. Formula entered in the D5 cell is =LARGE(B2:B6, 5). As a result, the function returns the #NUM! error value as the B2:B6 range does not contain numbers. 5. Formula entered in the D6 cell is =LARGE(A2:A6, 1). As a result, the function retrieves the 1st largest value from the sorted range. 234 LINEST Calculates parameters of the linear trend based on the least-squares method. Syntax =LINEST(known_data_y, [known_data_x], [calculate_b], [stats]) known_data_y — an array or a range of cells containing dependent (y) values that are already known. [known_data_x] (optional) — values of the independent variable(s) corresponding to known_data_y. If the argument is omitted, it is assumed to be an array of the same size as known_data_y. [calculate_b] (optional) — a logical value that determines whether to calculate the b (TRUE) or m (FALSE) variable in the y = m*x+b linear equation. If the argument is omitted, FALSE is used by default. [stats] (optional) — a logical value that determines whether to return the additional regression statistics for variables (TRUE) or to calculate only the b and/or m variables (FALSE). If the argument is omitted, FALSE is set by default. Notes The known_data_x and known_data_x datasets must be equal in size. Otherwise, the function returns the #REF! error. Examples A 1 B C Dataset1 Dataset2 2 4 3 5 4 3 5 8 D E Result 5 0.213740458 13 0.512 9 0.407272727 10 0.125 6 1. Formula entered in the C2 cell is as follows =LINEST(A2:A5, B2:B5, TRUE). As a result, the function returns returns the value of the b variable based on two equal-sized datasets. 235 2. Formula entered in the C3 cell is as follows =LINEST(A2:A5, B2:B5, FALSE). As a result, the function returns the value of the m variable based on the datasets in A2:A5 and B2:B5. 3. Formula entered in the C4 cell is as follows =LINEST(A2:A4, B2:B4, FALSE, TRUE). As a result, the function returns the additional regression statistics for the m variable based on two datasets. 4. Formula entered in the C5 cell is as follows =LINEST(A2:A4, B2:B4, TRUE, TRUE). As a result, the function returns the additional regression statistics for the b variable based on two datasets. 236 MAX Retrieves the maximum number from a numeric dataset. Syntax =MAX(value1, [value2, ...]) value1 — the first number, range or array to consider when searching for the maximum number. [value2, ...] (optional) — additional numbers, ranges or arrays of values to consider. Notes • If a range or an array contains non-numeric values, MAX ignores them. • MAX supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. • If a non-numeric value is supplied directly to the formula argument, MAX returns the #VALUE! error. • The maximum number of the function arguments is limited to 255. Examples 1 A B C Data Result 2 25 #VALUE! 3 43 56 4 89 43 5 6 7 n/a 80 D E 80 89 -5 8 1. Formula entered in the B2 cell is as follows =MAX("value", 78, 19). As a result, the function checks the dataset for the maximum number and returns the #VALUE! error as a text value is supplied to the formula argument. 237 2. Formula entered in the B3 cell is as follows =MAX("34", "56"). As a result, the function checks the numbers for the largest value ("34" and "56" presented as a string are casted to 34 and 56, respectively). 3. Formula entered in the B4 cell is as follows =MAX(A2, A3, A5). As a result, the function finds the largest number among the values in separate cell references. 4. Formula entered in the B5 cell is as follows =MAX(A2:A3, A6, 6). As a result, the function finds the maximum value in the dataset. 5. Formula entered in the B6 cell is as follows =MAX(A2:A4). As a result, the function finds the largest number in the A2:A4 range. 6. Formula entered in the B7 cell is as follows =MAX({"text", -5}). As a result, the function finds the maximum value, ignoring a text value in the array. 238 MIN Retrieves the minimum number from a numeric dataset. Syntax =MIN(value1, [value2, ...]) value1 — the first number or range to consider when searching for the minimum number. [value2, ...] (optional) — additional numbers or ranges of values to consider. Notes • MIN ignores text values that may be in a range. • MIN supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. • If text values are entered directly to the formula arguments, MIN returns the #VALUE! error. • The maximum number of the function arguments is limited to 255. Examples A B 1 Data Result 2 21 3 n/a C D E -5 #VALUE! 4 39 1 5 97 21 6 1. Formula entered in the B2 cell is as follows =MIN("34","-5","15"). As a result, the function selects the minimum number among the numbers ("34","-5","15" presented as a string are casted to 34, -5 and 15, respectively). 2. Formula entered in the B3 cell is as follows =MIN("value", 10). As a result, the function returns the #VALUE! error as a text value is supplied directly to the formula. 239 3. Formula entered in the B4 cell is as follows =MIN(A2, A5, 1, 5). As a result, the function checks the supplied dataset for the minimum number. 4. Formula entered in the B5 cell is as follows =MIN(A2:A5). As a result, the function checks the range of cells for the minimum number. 240 NORM.DIST Returns the normal distribution function for the specified values of the arithmetic mean and the standard deviation. Syntax =NORM.DIST(x, mean, standard_deviation, cumulative) x — a value for which the normal distribution is calculated. mean — the arithmetic mean value of the distribution. standard_deviation — the standard deviation of the normal distribution function. cumulative — a logical value that specifies whether to return the normal cumulative distribution (TRUE or any negative or positive number) or probability mass (FALSE or 0) function. Notes • If any of the x, mean, standard_deviation arguments are non-numeric, NORM.DIST returns the #VALUE! error. • If standard_deviation is less than or equal to 0, NORM.DIST returns the #NUM! error. • If standard_deviation is less than or equal to 0, NORM.DIST returns the #NUM! error. Examples 1 A B C Data Result 2 35 #NUM! 3 44 0.006683519 4 59 0.439379586 D E 5 1. Formula entered in the B2 cell is as follows =NORM.DIST(12, 33, -30, TRUE). As a result, the function returns the #NUM! error as the standard deviation value is negative. 241 2. Formula entered in the B3 cell is as follows =NORM.DIST(A2, A3, A4, FALSE). As a result, the function returns the probability mass function based on the data specified in cells: A2 – a value for which the normal distribution is calculated; A3 – the arithmetic mean of the distribution; A4 – the standard deviation of the distribution. 3. Formula entered in the B4 cell is as follows =NORM.DIST(A2, A3, A4, TRUE). As a result, the function returns the cumulative distribution function based on the data specified in cells: A2 – a value for which the normal distribution is calculated; A3 – the arithmetic mean of the distribution; A4 – the standard deviation of the distribution. 242 RANK.EQ Arranges numeric values in ascending or descending order and determines the rank position of a specified value in a dataset. For duplicate values, a rank of the first value is assigned. Syntax =RANK.EQ(value, data, [is_ascending]) value — a numeric value which rank position is to be determined. data — an array or a range containing the dataset to consider. [is_ascending] (optional) — a logical value that indicates whether a values of the dataset must be considered in ascending (TRUE) or descending (FALSE) order. If the argument is omitted, FALSE is used by default. Notes • RANK.EQ ignores non-numeric values that might be in a range or an array. • If a number supplied to value is not available in the dataset, RANK.EQ returns the #N/A error value. Examples A 1 B C D E Data Result 2 17 1 3 23 #N/A 4 23 1 5 8 2 6 1. Formula entered in the B2 cell is as follows =RANK.EQ(5, {5, 6, 7}, TRUE). As a result, the function arranges the numbers in ascending order and returns the rank position of 5 in the array supplied directly to the formula. 2. Formula entered in the B3 cell is as follows =RANK.EQ(1, A2:A4). As a result, 243 the function arranges the numbers in descending order and returns the error value as number 1 is unavailable in the range. 3. Formula entered in the B4 cell is as follows =RANK.EQ(23, A2:A5). As a result, the function arranges the numbers in descending order and returns the rank position of 23. 4. Formula entered in the B5 cell is as follows =RANK.EQ(A4, A2:A4, TRUE). As a result, the function arranges the numbers in ascending order and returns the rank position of the value in cell B4. 244 SMALL Arranges a given numeric dataset in ascending order and returns a value based on its relative position where the smallest value takes the first position. Syntax =SMALL(data, n) data — an array or a range containing the numeric dataset to consider. n — the position of an element in the rank from smallest to largest. Notes • SMALL ignores non-numeric values that might be in a range or an array. • The n value must be greater than or equal to 1. Otherwise, SMALL returns the #NUM! error value. • SMALL supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. • SMALL covers both sorted and unsorted ranges and/or arrays. Examples 1 A B ID Data C D E Price Result 2 1 Apricot 45 34 3 2 Melon 23 21 4 3 Grapefruit 64 23 5 4 Peach 90 #NUM! 6 5 Orange 31 1 7 1. Formula entered in the D2 cell is as follows =SMALL({"18", "34", "23"}, 3). As a result, the function returns the 3rd smallest value from the array of numbers and converts the resulted value into its numeric representation ("18", "34" and "23" presented as a string are casted to 18, 34 and 23, respectively). 245 2. Formula entered in the D3 cell is as follows =SMALL({21, 94, 15}, 2). As a result, the function retrieves the 2nd smallest value from the supplied array. 3. Formula entered in the D4 cell is as follows =SMALL(C2:C6, 1). As a result, the function retrieves the 1st smallest value from the unsorted range. 4. Formula entered in the D5 cell is as follows =SMALL(B2:B6, 5). As a result, the function returns the #NUM! error as the B2:B6 range does not contain numbers. 5. Formula entered in the D6 cell is as follows =SMALL(A2:A6, 1). As a result, the function retrieves the 1st smallest value in the sorted range. 246 STDEV.S s P (x − mean)2 n−1 Calculates the standard deviation based on a sample. The standard deviation determines how far, on average, all values are located from their mean. Syntax =STDEV.S(value1, [value2, ...]) value1 — the first value or range which represents a sample of the population. [value2, ...] (optional) — additional values or ranges corresponding to a sample of the population. Notes • STDEV.S ignores empty cells, text and logical values which may be in the sample. • STDEV.S supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. • If the total number of numeric values is less than 2, STDEV.S returns the #DIV/0! error value. • The maximum number of the function arguments is limited to 255. Examples A B 1 Data Result 2 88 9.609023537 3 TRUE 7.187952884 4 5 6 C 74 55.154328933 n/a #DIV/0! 9.899494937 7 247 D E 1. Formula entered in the B2 cell is as follows =STDEV.S("23", "11", "30"). As a result, the function calculates the standard deviation of a set of numbers ("23", "11" and "30" presented as a string are casted to 23, 11 and 30, respectively). 2. Formula entered in the B3 cell is as follows =STDEV.S({23, 15}, {31, 17}). As a result, the function calculates the standard deviation of the values specified in the arrays. 3. Formula entered in the B4 cell is as follows =STDEV.S(A2, A5, 10). As a result, the function calculates the standard deviation of a set of data containing a reference to a text value. 4. Formula entered in the B5 cell is as follows =STDEV.S(A5, 10). As a result, the function returns an error value as the function assumes at least 2 numeric values are supplied. 5. Formula entered in the B6 cell is as follows =STDEV.S(A2:A4). As a result, the function calculates the standard deviation of values in the A2:A4 range. A logical value in cell A3 is ignored. 248 VAR Calculates the variance based on a given sample. Syntax =VAR(value1, [value2, ...]) value1 — the first value, array or range of a sample. [value2, ...] (optional) — additional values, arrays or ranges of a sample. Notes • VAR ignores empty cells and text values which may be in the sample. • VAR considers logical values if they are supplied directly to the formula arguments. TRUE is evaluated to 1 and FALSE – to 0. • VAR supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. • If the total number of values is less than 2, VAR returns the #DIV/0! error value. • The maximum number of the function arguments is limited to 255. Examples A B 1 Data Result 2 10 3 17 6.666666667 4 24 #DIV/0! 5 value C D E 67 49 6 1. Formula entered in the B2 cell is as follows =VAR("5", "10", "21"). As a result, the function calculates the variance for a set of numbers ("5", "10" and "21" presented as a string are casted to 5, 10 and 21, respectively). 2. Formula entered in the B3 cell is as follows =VAR({10, 12}, {16, 14}). As a result, the function calculates the variance for the arrays of values. 249 3. Formula entered in the B4 cell is as follows =VAR(A5, 25). As a result, the function returns the #DIV/0! error as cell A5 contains a text value that is ignored. 4. Formula entered in the B5 cell is as follows =VAR(A2:A4). As a result, the function calculates the variance for the values in the supplied range. 250 VARA Calculates the variance based on a sample, treating text values as 0 (zero). Syntax =VARA(value1, [value2, ...]) value1 — the first value, array, or range of a sample. [value2, ...] (optional) — additional values, arrays, or ranges of a sample. Notes • VARA ignores empty cells which may appear in the sample. • VARA considers logical values in calculation. TRUE is evaluated to 1 and FALSE – to 0. • VARA supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. • If the total number of values is less than 2, VARA returns the #DIV/0! error value. • The maximum number of the function arguments is limited to 255. Examples 1 A B Data Result 2 C E 9 #DIV/0! 3 14 28 4 0 39 5 undefined 50 6 FALSE 0.5 7 D 48.25 8 1. Formula entered in the B2 cell is as follows =VARA(45). As a result, the function returns the #DIV/0! error as the function assumes that a set of values is supplied. 251 2. Formula entered in the B3 cell is as follows =VARA("5", "15", "13"). As a result, the function calculates the variance of numbers ("5", "15" and "13" presented as a string are casted to 5, 15 and 13, respectively). 3. Formula entered in the B4 cell is as follows =VARA({14, 20}, {5, 15}). As a result, the function calculates the variance of numbers in the arrays. 4. Formula entered in the B5 cell is as follows =VARA(A5, 10). As a result, the function calculates the variance of the dataset including a text value (which is treated as 0). 5. Formula entered in the B6 cell is as follows =VARA(A6, 1). As a result, the function calculates the variance of the dataset where cell A6 contains a logical value. 6. Formula entered in the B7 cell is as follows =VARA(A2:A5). As a result, the function calculates the variance of numbers in the range. 252 VARPA N 1 X (xi − x̄)2 N i=1 Analyses data in a range and returns the variance of that data range. Text and logical values are considered. Syntax =VARPA(value1, [value2, ...]) value1 — the first value representing an entire population. [value2, ...] (optional) — subsequent value(s) representing an entire population. Notes • If an argument is a text, it is casted to 0. • An argument containing TRUE is casted to 1; an argument containing FALSE is casted to 0 (zero). • Cells with empty values are ignored. • VARPA supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. • The maximum number of the function arguments is limited to 255. Examples 1 A B C Data Result 2 text 4 3 FALSE 141.1875 4 4 5 4 1.25 6 253 D E 1. Formula entered in the B2 cell is =VARPA(A2:A5). As a result, the function returns the variance of values specified in the A2:A5 range, that is equal to 4. 2. Formula entered in the B3 cell is =VARPA(5, 8, 11, 35). As a result, the function returns the variance of the entire population of 5, 8, 11 and 35, that is equal to 141.1875. 3. Formula entered in the B4 cell is =VARPA(10, 11, "9", "12"). As a result, the function returns the variance of the entire population of 10, 11, 9 and 12 ("9" and "12" are casted to 9 and 12, respectively), that is equal to 1.25. 254 Chapter 11 Financial functions 255 COUPPCD Returns a numeric date value of the last coupon date before the settlement date of a security. Syntax =COUPPCD(settlement, maturity, frequency, [day_count_convention]) settlement — a date after issuance when a security is delivered to a buyer. maturity — an expiration date of a security. frequency — an integer representing the number of coupon payments per year: 1 – annual payments; 2 – semi-annual payments; 4 – quarterly payments. [day_count_convention] (optional) — a number indicating which day count method to use: • 0 or omitted – the US (NASD) 30/360 standard assumes a year of 360 days and each month consisting of 30 days. • 1 – actual/actual represents an actual length of a month and a year (including a leap year which consists of 366 days). • 2 – actual/360 represents an actual length of a month and a year consisting of 360 days. • 3 – actual/365 assumes an actual length of a month and a year consisting of 365 days. • 4 – the European 30/360 standard assumes a year of 360 days and each month consisting of 30 days. Notes • The application stores dates as numeric date values beginning with December 30, 1899 ("zero" date). A numeric date value indicates the number of days that has passed since the "zero" date. • If the maturity date value precedes the settlement date, the function displays the #NUM! error. 256 • Date and time formats may vary depending on the regional preferences set on your computer. • To ensure the settlement and maturity arguments are entered correctly, use the DATE function or make a reference to a cell containing a date or a function returning a date type. • If either settlement or maturity is entered directly to the formula, a date value must be presented as a string, e.g. "1/10/2017". Examples A 1 B C E Settlement Date Maturity Date Result 2 03/01/2015 06/12/2017 41985 3 09/21/2001 10/13/2007 36812 4 5 D 37250 5/30/2015 5/21/2010 #NUM! 6 1. Formula entered in the C2 cell is =COUPPCD(A2, B2, 2, 1). The function determines the last coupon date before the settlement date based on the following data: the settlement date of the security – 03/01/2015; the maturity date of the security – 06/12/2017; the number of coupon payments per year – 2; the day count method – actual/actual. As a result, the function returns the 41985 numeric date value which corresponds to December 12, 2014. 2. Formula entered in the C3 cell is =COUPPCD(A3, B3, 1). The function determines the last coupon date before the settlement date based on the following data: the settlement date of the security – 09/21/2001; the maturity date of the security – 10/13/2007; the number of coupon payments per year – 1; the day count method – US (NASD) 30/360. As a result, the function returns the 36812 numeric date value which corresponds to October 13, 2000. 3. Formula entered in the C4 cell is =COUPPCD(DATE(2002, 3, 20), DATE(2003, 12, 25), 4, 4). The function determines the last coupon date before the settlement date based on the following data: the settlement date of the security – 03/20/2002; the maturity date of the security – 12/25/2003; the number of coupon payments per year – 4; the day count method – European 30/360. As a result, the 257 function returns the 37250 numeric date value which corresponds to December 25, 2001. 4. Formula entered in the C5 cell is =COUPPCD(A5, B5, 2, 3). As a result, the function returns the #NUM! error as, based on the data specified in cells A5 and B5, the maturity date of the security precedes its settlement date. 258 DOLLARDE Converts a dollar value expressed as a fraction into a decimal number. The function is primarily intended for calculations involving security prices. Syntax =DOLLARDE(fractional_price, unit) fractional_price — a number which consists of a whole part and a fractional part (used as a nominator of a fraction), separated by a decimal point. unit — a number used as a denominator of a fraction. Notes • DOLLARDE supports numbers presented as strings, e.g. "3". The resulted value is recognized as a number. • If unit is a negative number, the #NUM! error is displayed. • If unit equals 0 (zero), the function returns the #DIV/0! error. • If unit is presented as a decimal, its fractional part is dropped. Examples A B C 1 Data Result 2 5.5 3 4.004 D E 4.01 4 4 5 #NUM! 6 1. Formula entered in the B2 cell is =DOLLARDE(5.1, 2). As a result, the function converts the 5 21 fraction to its decimal presentation, that is equal to 5.5. 2. Formula entered in the B3 cell is =DOLLARDE(A3, 4). As a result, the function converts the 4 0.04 fraction to its decimal presentation, that is equal to 4.01. 4 259 3. Formula entered in the B4 cell is =DOLLARDE(2.4, 2). As a result, the function converts the 2 24 fraction to its decimal presentation, that is equal to 4. 4. Formula entered in the B5 cell is =DOLLARDE(3.1, -1). As a result, the function returns the #NUM! error as the denominator is supplied as a negative number. 260 DOLLARFR Converts a dollar value expressed as a decimal number into a fractional number. The function is primarily intended for calculations involving security prices. Syntax =DOLLARFR(decimal_price, unit) decimal_price — a decimal number. unit — a number used as a denominator of a returned fraction. Notes • DOLLARFR supports numbers presented as strings, e.g. "3". The resulted value is recognized as a number. • If unit is a negative number, the #NUM! error is displayed. • If unit equals 0 (zero), the function returns the #DIV/0! error. • If unit is presented as a decimal, its fractional part is dropped. Examples A B C 1 Data Result 2 0.3 3 1.625 D E 1.5 4 -4.4 5 #NUM! 6 1. Formula entered in the B2 cell is =DOLLARFR(0.75, 4). As a result, the function converts the 0.75 decimal to the 43 fraction and returns 0.3. 2. Formula entered in the B3 cell is =DOLLARFR(A3, 8). As a result, the function converts the 1.625 decimal to the 1 58 fraction and returns 1.5. 261 3. Formula entered in the B4 cell is =DOLLARFR(-4.8, 5). As a result, the function converts the -4.8 decimal to the −4 54 fraction and returns -4.4. 4. Formula entered in the B5 cell is =DOLLARFR(5.11, -1). As a result, the function returns the #NUM! error as the denominator is supplied as a negative number. 262 IRR Calculates the internal rate of return on an investment based on regular cash flows which include both payments and incomes. Syntax =IRR(cashflow_amounts, [rate_guess]) cashflow_amounts — an array or a range of cells containing incomes and payments associated with the investment. [rate_guess] (optional) — an estimate on the internal rate of return. If the argument is omitted, 0.1 is used by default. Notes • The cashflow_amounts argument must contain both payments and incomes on an investment. To indicate the expenses you have incurred, enter a negative value and use positive values for incomes. • Avoid using a currency sign if cash flows are supplied directly to an array; otherwise, IRR returns the #VALUE! error. • IRR ignores non-numbers which may appear in cashflow_amounts. • The cash flows considered in the calculation must be placed in the correct order starting with the investment amount (a negative value). Examples A B C 1 Periods Cash flows 2 0 −$5,500.00 3 1 $2,000.00 −35.46% 4 2 $1,000.00 −9.88% 5 3 $1,500.00 61.51% 6 4 $3,000.00 #DIV/0! 7 263 Result 12.45% D E 1. Formula entered in the C2 cell is as follows =IRR(B2:B6). As a result, the function returns the internal rate of return based on a $5,500.00 investment amount (cell B2) and income amounts for each particular period (B3:B6). 2. Formula entered in the C3 cell is as follows =IRR(B2:B4). As a result, the function returns the internal rate of return based on a $5,500.00 investment amount (cell B2) and income amounts for each particular period (B3:B4). 3. Formula entered in the C4 cell is as follows =IRR(B2:B5, 0.3). As a result, the function returns the internal rate of return based on a $5,500.00 investment amount (cell B2), income amounts for each particular period (B3:B4) and an estimate on the internal rate of return – 0.3. 4. Formula entered in the C5 cell is as follows =IRR({-3000, 2000, 1500, 5000}). As a result, the function returns the internal rate of return on an investment based on the cash flows specified in the array. 5. Formula entered in the C6 cell is as follows =IRR({1000, 2000, 3000, 4000}). As a result, the function returns the #DIV/0! error because the cashflows are specified as positive values. 264 NPV Returns a numeric value which is the net present value of an investment depending on a series of periodic cash flows and a discount rate. Syntax =NPV(discount, cashflow1, [cashflow2, ...]) discount — the investment discount rate for a period. cashflow1 — the first value of a series of future regular payments and income, i.e. cash flows. [cashflow2, ...] (optional) — additional values of a series of future regular payments and income, i.e. cash flows. Notes • NPV ignores non-numeric values that may be in a range or reference. • NPV assumes cash flows occur at regular intervals and considers them in the referenced order. Make sure the cash flows are indicated in the correct sequence. • Enter a positive value as a cash flow if it represents an income from the perspective of the owner of the investment (e.g. coupons), or a negative value if it represents payments (e.g. loan payment). • Avoid using a currency symbol if you supply cash flows directly to the formula. • NPV adds a locale-dependent currency symbol to the calculation result. • The maximum number of the cashflow arguments is limited to 254. 265 Examples 1 A B C Data Result 2 6% $4,516 3 -$9,000 $6,983 4 $500 -$6,786 5 $1,500 -$4,014 6 $3,500 -$53 7 $5,300 $5,586 8 $8,000 D E 9 1. Formula entered in the B2 cell is as follows =NPV(7%, -5000, -500, 2000, 3000, 8000). As a result, the function calculates the net present value of an investment based on the supplied cash flows and a 7% discount rate. 2. Formula entered in the B3 cell is as follows =NPV(5%, -3000, 500, 4200, 7000). As a result, the function calculates the present net value of an investment based on regular cashflows and a 5% discount rate. 3. Formula entered in the B4 cell is as follows =NPV(A2, A3:A5). As a result, the function calculates the present net value of an investment based on the terms specified in the A2:A5 range: data entered in cell A2 means a discount rate, A3 – an investment amount, A4 and A5 – return for the 1-st and 2-nd years respectively. 4. Formula entered in the B5 cell is as follows =NPV(A2, A3:A6). As a result, the function calculates the net present value of an investment based on the terms in the A2:A6 range: data entered in cell A2 means a discount rate, A3 – an investment amount, A4, A5 and A6 – return for the 1-st, 2-nd and 3-d years respectively. 5. Formula entered in the B6 cell is as follows =NPV(A2, A3:A7). As a result, the function calculates the net present value of an investment based on the terms in the A2:A7 range: data entered in cell A2 means a discount rate, A3 – an investment amount, A4, A5, A6 and A7 – return for the 1-st, 2-nd, 3-d and 4-th years respectively. 6. Formula entered in the B7 cell is as follows =NPV(A2, A3:A8). As a result, the 266 function calculates the net present value of an investment based on the terms in the A2:A8 range: data entered in cell A2 means a discount rate, A3 – an investment amount, A4, A5, A6, A7 and A8 – return for the 1-st, 2-nd, 3-d, 4-th and 5-th years respectively. 267 PMT Returns the periodic payment for an annuity based on constant periodic payments and a constant interest rate. Syntax =PMT(rate, number_of_payments, present_value, [future_value], [end_or_begin rate — an annual interest rate. number_of_payments — the number of payments for the annuity to be made. present_value — the current amount of a loan. [future_value] (optional) — a future amount to obtain after the final payment. If the argument is omitted, 0 (zero) is set by default. [end_or_beginning] (optional) — a number that indicates whether payments are due at the end (0) or beginning (1) of each period. If the argument is omitted, 0 (zero) is set by default. Notes • Make sure rate and number_of_payments are set consistently depending on whether the payments are due monthly or quarterly. For example, a loan for 2 years with monthly payments assumes the interest rate is divided by 12, and number_of_payments is 24. If a loan of the same length is paid out quarterly, the number of payments should be supplied as 8, and the annual interest rate – divided by 4. • PMT allows you to calculate the amount of savings that needs to be deposited monthly or quarterly to obtain the desired amount at the end of the payment period. To do this, supply 0 to present_value and indicate the amount you want to obtain in future_value. • Avoid using a currency symbol if you supply an amount directly to the formula. • PMT adds the local-dependent currency symbol to the calculation result. 268 Examples 1 A B Data Result 2 -$439 3 -$1,321 4 -$804 5 7% -$433 6 12 -$430 7 C D E $5,000.00 -$1,305 8 1. Formula entered in the B2 cell is as follows =PMT(5%/12, 24, 10000). As a result, the function calculates monthly payments for a $10000 loan taken for 2 years at a 5% interest rate. 2. Formula entered in the B3 cell is as follows =PMT(5%/4, 8, 10000). As a result, the function calculates quarterly payments for a $10000 loan taken for 2 years at a 5% interest rate. 3. Formula entered in the B4 cell is as follows =PMT(12%/12, 36, 0, 35000, 1). As a result, the function calculates the amount of monthly payments on a deposit at a 12% of an annual interest rate to be made to obtain $35000 in 3 years. The payments are due at the beginning of each month. 4. Formula entered in the B5 cell is as follows =PMT(A5/12, A6, A7). As a result, the function calculates the monthly payments for a loan based on the specified terms: an annual interest rate which is specified in cell A5, the number of months for payments – cell A6, and a loan amount – cell A7. 5. Formula entered in the B6 cell is as follows =PMT(A5/12, A6, A7, 0, 1). As a result, the function calculates the monthly payments for a loan based on the specified terms: an annual interest rate which is specified in cell A5, the number of months for payments – cell A6, and a loan amount – cell A7. The payments are due at the beginning of the period. 6. Formula entered in the B7 cell is as follows =PMT(A5/4, 4, A7). As a result, the 269 function calculates the quarterly payments on a $5000 loan for 1 year at a 7% annual interest rate. 270 PV Returns the present value of an investment based on constant payments and a constant interest rate. The function is intended to determine whether the future cashflows are worth being invested as the purchasing power of money falls over time, i.e. the real value of money decreases. Syntax =PV(rate, number_of_periods, payment_per_period, [future_value], [end_or_beginning]) rate — an interest rate. number_of_periods — the number of payments to be made. payment_per_period — an amount per period to be paid. Enter a negative number if you pay the amount and positive if you receive it. [future_value] (optional) — an amount you want to attain after the last payment is made. If the argument is omitted, 0 is used by default. [end_or_beginning] (optional) — a number that indicates whether payments are due at the end (0) or beginning (1) of each period. If the argument is omitted, 0 is used by default. Notes • Make sure rate, number_of_periods and payment_per_period are set consistently depending on whether the payments are due monthly or quarterly. For example, a loan for 2 years with monthly payments assumes the interest rate is divided by 12, and number_of_periods is set to 24. If a loan of the same length is paid out quarterly, the number of payments should be supplied as 8, and the annual percentage rate – divided by 4. • PV allows calculating the present value of a deposit based on monthly or quarterly payments. To do this, enter 0 to payment_per_period and indicate the amount you want to obtain in future_value. • Avoid using a currency symbol if you supply cash flows directly to the formula. • PV adds a local-dependent currency symbol to the calculation result. 271 Examples 1 A B C Data Result 2 $11,397 3 $11,352 4 -$18,871 5 8% $14,796 6 5 $14,894 7 -$300.00 $14,716 D E 8 1. Formula entered in the B2 cell is as follows =PV(5%/12, 24, -500). As a result, the function calculates the present value of a loan taken for 2 years at a 5% interest rate. The amount of $500 is paid out every month. 2. Formula entered in the B3 cell is as follows =PV(5%/4, 8, -500*3). As a result, the function calculates the present value of a loan taken for 2 years at a 5% interest rate. The amount of $500 is paid out every month, thus, it should be multiplied by 3. 3. Formula entered in the B4 cell is as follows =PV(12%/12, 36, 0, 27000, 1). As a result, the function calculates the present value of a 3-year deposit with monthly payments at a 12% annual interest rate. The payments are due at the beginning of each month. 4. Formula entered in the B5 cell is as follows =PV(A5/12, A6*12, A7). As a result, the function calculates the present value of a loan based on the specified terms: an annual interest rate which is specified in cell A5, the number of years for payments – cell A6, and an amount to be paid every month – cell A7. 5. Formula entered in the B6 cell is as follows =PV(A5/12, A6*12, A7, 0, 1). As a result, the function calculates the present value of a loan based on the specified terms: an annual interest rate which is specified in cell A5, the number of years for payments – cell A6, and an amount to be paid every month – cell A7. The payments are due at the beginning of the period. 6. Formula entered in the B7 cell is as follows =PV(A5/4, A6*4, A7*3). As a result, 272 the function calculates the present value of a loan for 5 years at an 8% annual interest rate. 273 ISSUE REOPENED 274 Chapter 12 Text functions 275 ASC Converts a text encoded in a double byte character set (DBCS) to a text in a single byte character set (SBCS). Syntax =ASC(string) string — a text or a reference to a cell containing a text to be converted. Notes • The table editor uses the UTF-8 encoding for presenting internal strings. Thus, fullwidth characters are automatically converted to halfwidth ones being entered in the application, and vice versa. The function is only used for the backward compatibility with documents containing text encoded in DBCS. • If a text does not contain any fullwidth characters, it is then not altered. Examples 1 2 A B C Data Result D E 567 3 v a l u e value 4 index 5 1. Formula entered in the B2 cell is =ASC("567"). As a result, the specified text is not altered as it does not contain any fullwidth characters. 2. Formula entered in the B3 cell is =ASC(A3). As a result, the function converts the fullwidth characters to the halfwidth characters. 3. Formula entered in the B4 cell is =ASC(JIS("index")). As a result, the function converts the fullwidth characters to the halfwidth characters. 276 CLEAN Removes non-printable characters from a given string. Syntax =CLEAN(text) text — a string from which non-printable characters are to be removed. Notes • Unicode characters from 0 to 31 are considered as non-printable. Examples A B 1 Data Result 2 value2 value 3 C D E 23 4 Chapter Chapter2 5 0 6 1. Formula entered in the B2 cell is =CLEAN(A2). Cell A2 contains ="value"&UNICHAR(12). As a result, the CLEAN function removes a non-printable character to which the UNICHAR function refers. 2. Formula entered in the B3 cell is =CLEAN("23"&CHAR(1)). As a result, the function removes a non-printable character to which the CHAR function refers. 3. Formula entered in the B4 cell is =CLEAN(A4&UNICHAR(50)). As a result, the function displays the U+0032 unicode character, that corresponds to 2, as it is a printable character. 4. Formula entered in the B5 cell is =LEN(CLEAN(UNICHAR(12))). As a result, the CLEAN function removes a non-printable character to which the UNICHAR function 277 refers and returns an empty value. On counting the number of characters in the result string, the LEN function returns 0. 278 CODE Returns the Unicode numeric value of the first character in a given string. Syntax =CODE(string) string — a text in which the first character is to be evaluated for the Unicode numeric value. Notes • The CODE function is limited to the first 255 Unicode characters. The characters after the first 255 are recognized as a question (?) mark and as a result the function returns 63. To correctly handle other characters, use the UNICODE function. Examples A B C 1 Data Result 2 118 3 4 5 N/A 12 D E 78 49 82 6 1. Formula entered in the B2 cell is =CODE("value"). As a result, the function returns the Unicode numeric value of the first character, that is equal to 118. 2. Formula entered in the B3 cell is =CODE(A3). As a result, the function returns the Unicode numeric value of the first character, that is equal to 78. 3. Formula entered in the B4 cell is =CODE(A4). As a result, the function returns the Unicode numeric value of the first character, that is equal to 49. 4. Formula entered in the B5 cell is =CODE(UPPER("row")). As a result, the function returns the Unicode numeric value of the capital letter R, that is equal to 82. 279 CONCATENATE Joins separate entries into a single string. Syntax =CONCATENATE(string1, [string2, ...]) string1 — the first entry. [string2, ...] (optional) — additional entries to be joined in sequence. Notes CONCATENATE displays an output value in one word. To separate entries, use one of the tips below: • Enter double quotation marks with a space between them (" ") as an argument. • Put a space either after or before the entry to be separated depending on its position in a string. For example, enter "Value " to separate the following string and " process" for a precedent string. The maximum number of the function arguments is limited to 255. Examples 1 A B C Data Result 2 45 computer science 3 10 4510 D E 4 5 6 1. Formula entered in the B2 cell is =CONCATENATE("computer", " ", "science"). As a result, the function returns the entries appended one after another. 2. Formula entered in the B3 cell is =CONCATENATE(A2, A3). As a result, the function returns the values in cells A2 and A3 appended one after another. 280 Conversion functions: JIS and DBCS Used for converting a text from ASCII to DBCS and backwards. To this end, the following functions can be applied: JIS and DBCS, respectively. JIS converts ASCII text where characters are only 1 byte in length and returns a changed text encoded in a double byte character set (DBCS). It is identical to the DBCS function. As the table editor uses the UTF-8 encoding for presenting internal strings, thus, fullwidth characters are automatically converted to halfwidth ones being entered in the application, and vice versa. As a result, no conversion occurs when using the JIS or the DBCS function. It is only used for the backward compatibility with documents containing text encoded in either ASCII or DBCS; these are documents exported from the other applications. Syntax =JIS(string) and =DBCS(string) string — a text or a reference to a cell containing a text to be converted. Notes • If a text does not contain any halfwidth characters, it is then not altered. Examples 1 A B Data Result C 12345 3 未練なく散も桜はさくら哉 未 練 な く 散 も 桜 は さ く ら 哉 2 4 1. Formula entered in the B2 cell is =JIS("12345"). As a result, the function converts the halfwidth characters to the fullwidth characters. 2. Formula entered in the B3 cell is =DBCS(A3). As a result, the function converts the halfwidth characters to the fullwidth characters. 281 EXACT Checks whether two strings are identical and, if so, returns TRUE. Syntax =EXACT(string1, string2) string1 — the first string that is to be compared with the second string for identity. string2 — the second string that is to be compared with the first string for identity. Notes • Uppercase and lowercase values are not considered as equivalent as the function is case-sensitive. • EXACT checks for identical spaces and hidden characters when comparing two strings. Examples A B C 1 Data Result 2 id 3 4 D E FALSE FALSE ID TRUE 5 1. Formula entered in the B2 cell is =EXACT(A2, A4). As a result, the function returns FALSE as the strings in cells A2 and A4 differ in case, thus, they are not identical. 2. Formula entered in the B3 cell is =EXACT("12", " 12"). As a result, the function returns FALSE as the second string starts with a space, thus, the strings are not identical. 3. Formula entered in the B4 cell is =EXACT("value", "value"). As a result, the function returns TRUE as the supplied strings are identical. 282 FIND and FINDB The FIND function searches for a string within a text and returns a character number at which the search string starts in the text. The function is case-sensitive. In the table editor, the FIND and FINDB functions work identically as the UTF-8 encoding is used for presenting internal strings. For more information, see Conversion functions: JIS and DBCS. Syntax =FIND(search_for, text_to_search, [starting_at]) =FINDB(search_for, text_to_search, [starting_at]) search_for — a string to be searched for within text_to_search. text_to_search — a text within which to search for the first occurrence of search_for. [starting_at] (optional) — a character number within text_to_search at which to start searching. If the argument is omitted, 1 is used by default. Notes • By default, FIND looks for the first occurrence of a search value. In case text_to_search contains several search keys, you can set starting_at to specify the character number at which to start the search and, thus, define the next position of the specified search value. • The value supplied to starting_at must be greater than or equal to 1. Otherwise, FIND returns the #VALUE! error. • White spaces and punctuation marks are considered as individual characters. • To perform a case-insensitive search, use the equivalent SEARCH and SEARCHB function. 283 Examples A B 1 Data Result 2 Apple 3 Banana 4 4 Mango 1 5 C D E #VALUE! 6 6 1. Formula entered in the B2 cell is =FIND("gn", A2). As a result, the function evaluates the string in cell A2 for the search key and returns the #VALUE! error as no match is found. 2. Formula entered in the B3 cell is =FIND("an", A3, 4). As a result, the function starts searching at the forth character and returns the position of the second occurrence of "an" in cell A3. 3. Formula entered in the B4 cell is =FIND("Ma", A4). As a result, the function returns the position of the "Ma" value in cell A4. 4. Formula entered in the B5 cell is =FIND("2", "224562", 3). As a result, the function starts searching at the third character of the string and returns the position of the third occurrence of "2". 284 LEFT and LEFTB The LEFT function returns a substring from the left side of a string based on the supplied number of characters. In the table editor, the LEFT and LEFTB functions work identically as the UTF-8 encoding is used for presenting internal strings. For more information, see Conversion functions: JIS and DBCS. Syntax =LEFT(string, [number_of_characters]) =LEFTB(string, [number_of_characters]) string — a string from which a substring is to be returned. [number_of_characters] (optional) — the number of substring characters to be returned from string. If the argument is omitted, 1 is used by default. Notes • LEFT handles both text and numeric values, but the result is recognized as a string. • The number_of_characters value must be greater than or equal to 0 (supplying 0 results in an empty cell). Otherwise, LEFT returns the #VALUE! error. • If the number_of_characters value exceeds the actual length of string, the whole string is returned. Examples 1 A B Data Result 2 min 3 50 4 54 5 5 undefined #VALUE! 6 C D E - 7 1. Formula entered in the B2 cell is =LEFT("minimum", 3). As a result, the function returns the first 3 characters of the supplied string. 285 2. Formula entered in the B3 cell is =LEFT(5090, 2). As a result, the function returns the first 2 characters of the "5090" string. 3. Formula entered in the B4 cell is =LEFT(A4). As a result, the function returns the first character of the string in cell A4. 4. Formula entered in the B5 cell is =LEFT(A5, -1). As a result, the function returns the #VALUE! error as the number of characters to return is less than 0. 5. Formula entered in the B6 cell is =LEFT(-5). As a result, the function returns the first character of the supplied string. 286 LEN and LENB The LEN function returns the count of characters in a supplied string. In the table editor, the LEN and LENB functions work identically as the UTF-8 encoding is used for presenting internal strings. For more information, see Conversion functions: JIS and DBCS. Syntax =LEN(text) =LENB(text) text — a string in which the number of characters is to be counted. Notes • LEN counts all characters, including spaces and nonprinting characters. Examples A B C 1 Data Result 2 8 3 5 4 4 D E 5 1. Formula entered in the B2 cell is =LEN("Col Tex!"). As a result, the function returns the count of characters in the string supplied directly to the formula. 2. Formula entered in the B3 cell is =LEN("875.6"). As a result, the function returns the count of characters in the supplied string. 3. Formula entered in the B4 cell is =LEN("text"). As a result, the function returns the number of characters in the supplied string. 287 LOWER Finds uppercase letters in a given string to convert them to lowercase. Syntax =LOWER(text) text — a string to be converted to lowercase. Examples 1 A B C Data Result 2 pro 3 15num 4 D E APPLE apple 5 1. Formula entered in the B2 cell is as follows =LOWER("Pro"). As a result, the function converts the string supplied directly to the formula to lowercase. 2. Formula entered in the B3 cell is as follows =LOWER("15NUM"). As a result, the function returns the string converted to lowercase. 3. Formula entered in the B4 cell is as follows =LOWER(A4). As a result, the function converts the string in cell A4 to lowercase. 288 MID and MIDB The MID function extracts a substring from a string. In the table editor, the MID and MIDB functions work identically as the UTF-8 encoding is used for presenting internal strings. For more information, see Conversion functions: JIS and DBCS. Syntax =MID(string, starting_at, extract_length) =MIDB(string, starting_at, extract_length) string — a string from which to extract a substring. starting_at — a character in string at which to start extracting. The first character is set to 1. extract_length — a number which determines the length of a substring. Notes • If starting_at is greater than the actual length of string, MID returns an empty value. • The starting_at value must be greater than or equal to 1; otherwise, MID returns the #VALUE! error. • If the extract_length value is greater than the actual length of the initial string, MID returns the whole string without any trailing spaces. Examples 1 A B C Data Result D E 2 3 7 4 Orange #VALUE! 5 Apple pl 6 1. Formula entered in the B2 cell is as follows =MID("cover", 6, 1). As a result, the function returns an empty cell because the starting point is greater than the actual 289 length of the supplied string. 2. Formula entered in the B3 cell is as follows =MID(675, 2, 1). As a result, the function starts extracting at the second character and returns 1 character from the string. 3. Formula entered in the B4 cell is as follows =MID(A4, 0, 7). As a result, the function returns the #VALUE! error as the character at which the extraction must be started is set to 0. 4. Formula entered in the B5 cell is as follows =MID(A5, 3, 2). As a result, the function starts extracting at the third character and returns 2 characters from the string in cell A5. 290 PROPER Capitalizes the first letter of every word in a specified string. Syntax =PROPER(text_to_capitalize) text_to_capitalize — a string in which the first letter of every word is to be returned in uppercase, and all other letters – in lowercase. Notes • PROPER ignores non-letter characters in a string. For example, "d&g" will be converted to "D&G". Examples 1 2 3 A B Data Result C D E Atlantic Ocean operating system Operating System 4 Sunday 5 3-Day Trip 6 1. Formula entered in the B2 cell is =PROPER("atlantic ocean"). As a result, the function returns the string in which the first letter of every word is capital. 2. Formula entered in the B3 cell is =PROPER(A3). As a result, the function capitalizes the first letter of every word in the string specified in cell A3. 3. Formula entered in the B4 cell is =PROPER("sun"&UPPER("day")). As a result, the function returns the string in which the first letter is capital, and other letters are small. 4. Formula entered in the B5 cell is =PROPER("3-day trip"). As a result, the func291 tion ignores non-letter characters and displays the first letter of every word in uppercase. 292 RIGHT and RIGHTB The RIGHT function returns the rightmost character or characters of a given string. In the table editor, the RIGHT and RIGHTB functions work identically as the UTF-8 encoding is used for presenting internal strings. For more information, see Conversion functions: JIS and DBCS. Syntax =RIGHT(string, [number_of_characters]) =RIGHTB(string, [number_of_characters]) string — a string from which the right portion is to be returned. [number_of_characters] (optional) — the number of characters to be returned from the rightmost part of string. If the argument is omitted, 1 is used by default. Notes • RIGHT handles both text and numeric values, but the result is recognized as a string. • The value supplied to number_of_characters must be greater than or equal to 0 (supplying 0 results in an empty string). Otherwise, RIGHT returns the #VALUE! error. • If the number_of_characters value exceeds the actual length of string, the whole string is returned. • RIGHT supports presenting numbers as a string, e.g. "15". The resulted value is recognized as a number. Examples 1 A B Data Result 2 and 3 45 4 undefined #VALUE! 5 48 8 6 293 C D E 1. Formula entered in the B2 cell is as follows =RIGHT("land", 3). As a result, the function returns the last 3 characters of the "land" value. 2. Formula entered in the B3 cell is as follows =RIGHT(78945, 2). As a result, the function retrieves the last 2 characters of the "78945" string. 3. Formula entered in the B4 cell is as follows =RIGHT(A4, -1). As a result, the function returns the #VALUE! error as the number of characters to return is less than 0. 4. Formula entered in the B5 cell is as follows =RIGHT(A5). As a result, the function retrieves the last character of the value in cell A5. 294 SEARCH and SEARCHB Return the starting position of a string within a text. Syntax =SEARCH(search_for, text_to_search, [starting_at]) =SEARCHB(search_for, text_to_search, [starting_at]) search_for — a string for which the function searches. text_to_search — a text, which the function searches. [starting_at] (optional) — a character number at which to start the search. If the argument is omitted, the function sets it to 1. Notes • SEARCH and SEARCHB ignore letter case. For a case sensitive search, use FIND and FINDB. • SEARCH and SEARCHB have identical behavior in MyOffice Spreadsheets because it uses UTF-8 encoding. However, only SEARCHB is fully compatible with applications that use DBCS encoding while working with Chinese, Japanese, or Korean text. For more information, see Conversion functions: JIS and DBCS. • If SEARCH cannot find the value of search_for, it returns the #VALUE! error. • If starting_at is less than 1 or greater than the length of text_to_search, SEARCH returns the #VALUE! error. • SEARCH supports wildcard characters. By default, it treats a question mark (?) as any single character and an asterisk (*) as any sequence of characters. To find an actual question mark or asterisk, type a tilde (~) before the character. • By default, SEARCH looks for the first occurrence of search_for. If text_to_search contains several search keys, you can skip some of them by changing the value of starting_at. 295 Examples 1 A B C Data Result 2 Value 1 3 234554 6 4 2 5 balance #VALUE! 6 price 1 7 price #VALUE! D E 8 1. Formula entered in the B2 cell is =SEARCH("va", A2). The function ignores upper case and returns the position of "va" in the A2 cell. 2. Formula entered in the B3 cell is =SEARCH("4", A3, 4). The function starts searching from the fourth character and returns the position of the second occurrence of "4" in the A3 cell. 3. Formula entered in the B4 cell is =SEARCH("2", "224562", 2). The function starts searching from the second character of the supplied string and returns the position of the second occurrence of "2". 4. Formula entered in the B5 cell is =SEARCH("na", A5). The function returns the #VALUE! error because no match is found in the A5 cell. 5. Formula entered in the B6 cell is =SEARCH("p?ice", A6). The function treats the question mark as a placeholder for any character and returns the position of "price" in the A6 cell. 6. Formula entered in the B7 cell is =SEARCH("p~*e", A7). The tilde turns the asterisk into a regular character. The function cannot find "p*e" in the A7 cell and returns the #VALUE! error. 296 SUBSTITUTE Replaces a specific string with another one in a text. Syntax =SUBSTITUTE(text_to_search, search_for, replace_with, [occurrence_number]) text_to_search — a text in which to replace a string. search_for — a string which is replaced with another one. replace_with — a new string which replaces an existing one. [occurrence_number] (optional) — a number that indicates the occurrence of the string to be replaced. If the argument is omitted, the function replaces all the occurrences of search_for. Notes • SUBSTITUTE is case-sensitive. • If a decimal number is entered to occurrence_number, it is truncated to an integer. • SUBSTITUTE can replace only one or all occurrences of search_for. In the following cases, the function returns text_to_search without modification: • search_for is not found in text_to_search. • [occurrence_number] exceeds the quantity of search_for occurrences. Examples 1 A B Data Result 2 JK098703 JK-987-3 3 DATA DATE 4 FOK2201 FOK2201 5 6 flow ISO 7945791 ISO 7945791 7 297 C D E 1. Formula entered in the B2 cell is =SUBSTITUTE(A2, "0", "-"). As a result, the function replaces all occurrences of 0 (zero) in cell A2 with a hyphen (-). 2. Formula entered in the B3 cell is =SUBSTITUTE(A3, "A", "E", 2). As a result, the function replaces the second occurrence of the character "A" with "E". 3. Formula entered in the B4 cell is =SUBSTITUTE(A4, "a", "9"). As a result, the function returns the text without modification because the character "a" is not available in cell A4. 4. Formula entered in the B5 cell is =SUBSTITUTE("row", "r", "fl"). As a result, the function replaces the character "r" with "fl". 5. Formula entered in the B6 cell is =SUBSTITUTE(A6,"79", "66", 10). The provided value of [occurrence_number] is 10, which is greater than the actual occurrence of "79" within "ISO 7945791". As a result, the function returns the text without any changes. 298 TEXT Converts a numeric value into a text value according to a specified format. Syntax =TEXT(value, format) value — a number, a date, or a time value to format. format — a formatting pattern, enclosed in double quotation marks, to apply to value. Below is a list of the most popular formats you can use within the function: • d for the day of the month (1 or 2 digits); • dd for the day of the month (2 digits); • ddd for a short name of the day of the week; • dddd for a full name of the day of the week; • m for the month of the year (1 or 2 digits); • mm for the month of the year (2 digits); • mmm for a short name of the month of the year; • mmmm for a full name of the month of the year in uppercase; • mmmmm for the first uppercase letter in the month of the year; • yy for the year (2 digits); • yyyy for the year (4 digits); • h for hours in time formatting (1 or 2 digits); • hh for hours in time formatting (2 digits); • am/pm for hours based on a 12-hour clock (displays AM or PM as appropriate); • m for minutes in time formatting (1 or 2 digits); • mm for minutes in time formatting (2 digits); • s for seconds in time formatting (1 or 2 digits); • ss for seconds in time formatting (2 digits); 299 • ms for milliseconds in time formatting; • 0 adds zeros to an entry; • # indicates a placeholder of an input number; • 0.00E+00 for the Scientific formatting; • 0% for the Percentage formatting; • # ?/? for the Fraction formatting; • #,### for a thousand separator (locale dependent). Notes • Format patterns are not case-sensitive, i.e. the yy and YY patterns represent the same year format. • By specifying 0 in format, TEXT adds leading zeros to an output if the number of digits in value exceeds the number of zeros supplied to format. Otherwise, the output value is returned without modifications. • To display hours on a 12-hour clock, enter a combination of formatting patterns: h or hh with am/pm. For example, =TEXT(56.78, "h am/pm") returns 6 PM. • By default, the m and mm patterns are treated as components of a month unless they are used as a part of time formatting, i.e. in combination with the h or hh patterns. For example, =TEXT(45, "m") returns 2 that corresponds to the second month of the year. • Date and time formats vary depending on the regional preferences set on your workstation. For example, =TEXT(567.893, "h:m am/pm") returns 9:25 PM for the US region. 300 Examples 1 2 A B C Data Result E Monday 3 35 $35 4 45.678 046 5 2489.45 6 1997/05/12 7 5:21 AM 8 D 34.89 2136 9 1. Formula entered in the B2 cell is as follows =TEXT(2, "dddd"). As a result, the function returns a full name of the second day of the week. 2. Formula entered in the B3 cell is as follows =TEXT(A3, "$00"). As a result, the function returns the value in cell A3 in currency format. 3. Formula entered in the B4 cell is as follows =TEXT(A4, "000"). As a result, the function rounds the value in cell A4 to the next greater number and adds a leading zero to the integer. 4. Formula entered in the B5 cell is as follows =TEXT(2489, "#.45"). As a result, the function adds a fractional part to the number and converts the output to a text value. 5. Formula entered in the B6 cell is as follows =TEXT(DATE(1997, 5, 12), "yyyy/mm/dd"). As a result, the function converts the date according to the specified format. 6. Formula entered in the B7 cell is as follows =TEXT(123.223, "h:m am/pm"). As a result, the function displays time on a 12-hour clock. 7. Formula entered in the B8 cell is as follows =TEXT(A8, "ms"). As a result, the function returns milliseconds in time formatting. 301 TRIM Evaluates a string for leading and trailing spaces as well as extra spaces (more than 1) between words and removes them. Syntax =TRIM(text) text — a string or a reference to a cell with a string to be considered. Examples 1 2 3 4 A B Data Result C D E Column PC Performance PC Performance 463 5 1. Formula entered in the B2 cell is =TRIM("Column "). As a result, the function removes the trailing space from the supplied string. 2. Formula entered in the B3 cell is =TRIM(A3). As a result, the function removes the leading spaces and odd spaces between words from the string in cell A3. 3. Formula entered in the B4 cell is =TRIM(" 463 "). As a result, the function removes all leading and trailing spaces from the supplied string. 302 UNICODE Returns the Unicode numeric value of the first character in a given string. Syntax =UNICODE(string) string — a text for which the Unicode numeric value is to be returned. Examples A B C 1 Data Result 2 85 3 range 114 4 44 52 5 D E 80 6 1. Formula entered in the B2 cell is =UNICODE("Union operator"). As a result, the function returns the Unicode numeric value of the first character, that is equal to 85. 2. Formula entered in the B3 cell is =UNICODE(A3). As a result, the function returns the Unicode numeric value of the first character in cell A3, that is equal to 114. 3. Formula entered in the B4 cell is =UNICODE(A4). As a result, the function returns the Unicode numeric value of the first character in cell A4, that is equal to 52. 4. Formula entered in the B5 cell is =UNICODE(UPPER("parameter")). As a result, the function returns the Unicode numeric value of the capital letter P, that is equal to 80. 303 UPPER Converts all lowercase letters in a specified string to uppercase. Syntax =UPPER(text) text — a string to be converted to uppercase. Examples 1 A B C Data Result 2 GOV 3 15COM 4 value VALUE D E 5 1. Formula entered in the B2 cell is as follows =UPPER("gov"). As a result, the function converts the string supplied directly to the formula to uppercase. 2. Formula entered in the B3 cell is as follows =UPPER("15com"). As a result, the function converts the letters of the string to uppercase. 3. Formula entered in the B4 cell is as follows =UPPER(A4). As a result, the function converts the string in cell A4 to uppercase. 304 Chapter 13 Information functions 305 CELL Returns the requested data about a particular cell. Syntax =CELL(info_type, [reference]) info_type — a type of the requested data: • "address" returns an absolute cell reference of the reference value. • "col" returns a column number based on the location of the supplied cell reference. Column A is set to 1. • "contents" returns a value that is in the cell of the reference argument. • "prefix" checks text alignment in a referenced cell and returns a single quotation mark (') for right-aligned text, a double quotation mark (") for left-aligned text, a backslash (\) for fill-aligned text and a caret (^) for centred text. In case a referenced cell contains a non-text value, the CELL function returns a single quotation mark ('). • "row" returns a row number based on the location of the specified cell reference. • "type" determines which data type is in the cell of the reference argument and returns one of the following values: "e" if a referenced cell is blank; "l" if a cell contains a string; "v" for other data types in a referenced cell. [reference] (optional) — a cell reference from which the requested data is to be returned. If the argument is omitted, the function defaults to the cell with the formula. Notes • The info_type value must be enclosed in double quotation marks. Otherwise, CELL returns the #VALUE! error. • If [reference] is specified as a range of cells, the CELL considers the upper leftmost cell in the calculation. 306 Examples A B C 1 Data Result 2 2 3 value l 4 - 5 D E $A$4 54 54 6 1. Formula entered in the B2 cell is =CELL("row"). As a result, the function returns a row number of the current cell, that is equal to 2. 2. Formula entered in the B3 cell is =CELL("type", A3). As a result, the function determines what data type is entered in cell A3 and returns "l" (as cell A3 contains a string). 3. Formula entered in the B4 cell is =CELL("address", A4). As a result, the function returns an absolute cell reference of cell A4, that is equal to $A$4. 4. Formula entered in the B5 cell is =CELL("contents", A5). As a result, the function returns the value in cell A5, that is equal to 54. 307 INFO Returns the requested information relating to the user’s operating system and the data processing environment. Syntax =INFO(info_type) info_type — a type of information that is to be returned. The argument must be presented as a string. • "numfile" – the number of sheets in the current workbook. • "osversion" – the current version of the operating system. The output value is recognised as a string. • "recalc" – the recalculation mode set in the current workbook: automatic or manual. • "release" – the current version of the table editor. The output value is recognised as a string. • "system" – the operating system name. Examples 1 A B Data Result 2 C D E 1 3 Online 4 Automatic 5 Online 6 Online 7 1. Formula entered in the B2 cell is as follows =INFO("numfile"). As a result, the function returns the number of sheets in the current workbook, that is 1. 2. Formula entered in the B3 cell is as follows =INFO("osversion"). As a result, the function returns the operating system version, that is "Online". 308 3. Formula entered in the B4 cell is as follows =INFO("recalc"). As a result, the function returns the recalculation mode set in the current workbook, that is "Automatic". 4. Formula entered in the B5 cell is as follows =INFO("release"). As a result, the function returns the current version of the table editor, that is "Online". 5. Formula entered in the B6 cell is as follows =INFO("system"). As a result, the function returns the operating system name, that is "Online". 309 ISBLANK Checks whether a referenced cell is empty, and if so, returns the TRUE logical value. Syntax =ISBLANK(value) value — a cell reference to consider. Notes • ISBLANK returns FALSE if a referenced cell contains any entries, including spaces (" ") and hidden characters. Examples A 1 2 3 B C D E Data Result TRUE 43 FALSE 4 1. Formula entered in the B2 cell is =ISBLANK(A2). As a result, the function returns TRUE as the A2 cell is empty. 2. Formula entered in the B3 cell is =ISBLANK(A3). As a result, the function returns FALSE as the A3 cell is filled. 310 ISERR Returns TRUE if a given value is an error other than #N/A. Syntax =ISERR(value) value — a value to be checked for an error type. Notes • ISERR returns FALSE if value is the #N/A error. • ISERR returns TRUE on any of the following error types: #DIV/0!, #NAME?, #NULL!, #NUM!, #VALUE!, #REF! and #GETTING_DATA. Examples 1 A B C Data Result 2 #NAME? TRUE 3 TRUE 4 #N/A D E FALSE 5 1. Formula entered in the B2 cell is =ISERR(A2). As a result, the function returns TRUE as the A2 cell contains an error other than #N/A. 2. Formula entered in the B3 cell is =ISERR(#NULL!). As a result, the function returns TRUE as the supplied error is other than #N/A. 3. Formula entered in the B4 cell is =ISERR(A4). As a result, the function returns FALSE as the A4 cell contains the #N/A error. 311 ISERROR Returns TRUE if a given value is an error. Syntax =ISERROR(value) value — a value to be checked for an error type. Examples 1 2 3 A B C Data Result D E FALSE #VALUE! TRUE 4 1. Formula entered in the B2 cell is =ISERROR("text"). As a result, the function returns FALSE as the supplied value is not an error. 2. Formula entered in the B3 cell is =ISERROR(A3). As a result, the function returns TRUE as the A3 cell contains the #VALUE! error. 312 ISEVEN Checks whether a value is an even number and, if so, returns TRUE. Syntax =ISEVEN(value) value — a value to be checked for an even number. Notes • If the argument contains or refers to a non-numeric value, the #VALUE! error is displayed. • ISEVEN supports numbers presented as strings, e.g. "10". The resulted value is recognized as a number. • If a decimal number is supplied to the argument, its fractional part is truncated. • If value is a reference to an empty cell, it is casted to 0. Examples 1 2 A B Data Result D E -2 TRUE 3 FALSE 4 63.3 FALSE 5 n/a 6 C #VALUE! TRUE 7 1. Formula entered in the B2 cell is =ISEVEN(A2). As a result, the function returns TRUE as cell A2 contains an even number. 2. Formula entered in the B3 cell is =ISEVEN(-45). As a result, the function returns FALSE as the supplied number is odd. 313 3. Formula entered in the B4 cell is =ISEVEN(A4). As a result, the function truncates the fractional part of the value in cell A4 and returns FALSE as number 63 is odd. 4. Formula entered in the B5 cell is =ISEVEN(A5). As a result, the function returns the #VALUE! error as cell A5 contains a text value. 5. Formula entered in the B6 cell is =ISEVEN(A6). An empty value in cell A6 is casted to 0. As a result, the function returns TRUE. 314 ISLOGICAL Checks whether a value is either FALSE or TRUE and returns TRUE on any of them. Syntax =ISLOGICAL(value) value — a value to be verified as a logical value. Examples A B 1 Data Result 2 TRUE TRUE 3 34 TRUE 4 C D E FALSE 5 1. Formula entered in the B2 cell is =ISLOGICAL(A2). As a result, the function returns TRUE as the value in cell A2 is a logical value. 2. Formula entered in the B3 cell is =ISLOGICAL(ISNUMBER(A3)). As a result, the function returns TRUE as the result of the ISNUMBER function is a logical value. 3. Formula entered in the B4 cell is =ISLOGICAL(45). As a result, the function returns FALSE as the supplied value is not a logical value. 315 ISNA Checks whether a value is the #N/A error and, if so, returns TRUE. Syntax =ISNA(value) value — a value to be tested for the #N/A error. Examples A B C 1 Data Result 2 FALSE 3 4 D E #N/A TRUE 89 FALSE 5 1. Formula entered in the B2 cell is =ISNA("cap"). As a result, the function returns FALSE as the supplied value is not the #N/A error. 2. Formula entered in the B3 cell is =ISNA(A3). As a result, the function returns TRUE as the A3 cell contains the #N/A error. 3. Formula entered in the B4 cell is =ISNA(A4). As a result, the function returns FALSE as the A4 cell does not contain the #N/A error. 316 ISNUMBER Checks whether a given value is a number. Syntax =ISNUMBER(value) value — a value to be tested for a number. Notes • ISNUMBER returns TRUE if a specified value is a number; otherwise, it returns FALSE. • ISNUMBER supports numbers presented as strings, e.g. "12", and evaluates them to TRUE. Examples A 1 2 3 4 B C D E Data Result 22 TRUE n/a FALSE TRUE 5 1. Formula entered in the B2 cell is =ISNUMBER(A2). As a result, the function returns TRUE as the A2 cell contains a number. 2. Formula entered in the B3 cell is =ISNUMBER(A3). As a result, the function returns FALSE as A3 is a reference to a non-numeric value. 3. Formula entered in the B4 cell is =ISNUMBER("34"). As a result, the function returns TRUE as "34" is casted to 34 (a numeric value). 317 ISODD Checks whether a value is an odd number and, if so, returns TRUE. Syntax =ISODD(value) value — a number to be verified as odd. Notes • If the argument contains or refers to a non-numeric value, the #VALUE! error is displayed. • ISODD supports numbers presented as strings, e.g. "10". The resulted value is recognized as a number. • If a decimal number is supplied to the argument, its fractional part is truncated. • If value is a reference to an empty cell, it is casted to 0. Examples 1 2 A B Data Result 23.7 TRUE 4 TRUE 6 D E -44 FALSE 3 5 C n/a #VALUE! FALSE 7 1. Formula entered in the B2 cell is =ISODD(A2). As a result, the function returns FALSE as cell A2 contains an even number. 2. Formula entered in the B3 cell is =ISODD(A3). As a result, the function truncates the fractional part of the value in cell A3 and returns TRUE as number 23 is odd. 318 3. Formula entered in the B4 cell is =ISODD(11). As a result, the function returns TRUE as the supplied number is odd. 4. Formula entered in the B5 cell is =ISODD(A5). As a result, the function returns the #VALUE! error as cell A5 contains a text value. 5. Formula entered in the B6 cell is =ISODD(A6). An empty value in cell A6 is casted to 0. As a result, the function returns FALSE. 319 ISREF Returns TRUE if a supplied value is a valid cell reference. Syntax =ISREF(value) value — a value to be tested as a cell reference. Examples A B C 1 Data Result 2 FALSE 3 25 TRUE 4 TRUE D E 5 1. Formula entered in the B2 cell is =ISREF("plan"). As a result, the function returns FALSE as the supplied value is not a valid reference. 2. Formula entered in the B3 cell is =ISREF(A3). As a result, the function returns TRUE as the supplied value is a valid cell reference. 3. Formula entered in the B4 cell is =ISREF(INDIRECT("A1")). As a result, the function returns TRUE as the INDIRECT function contains a valid reference. 320 ISTEXT Checks whether a given value is textual. Syntax =ISTEXT(value) value — a value to be checked as textual. Notes • ISTEXT returns TRUE if value contains or refers to a text value and FALSE otherwise. • If a referenced cell contains trailing spaces, ISTEXT returns TRUE. • If value is a reference to an empty cell, ISTEXT returns FALSE. • ISTEXT supports numbers presented as strings, e.g. "8", and evaluates them to TRUE. Examples 1 A B Data Result 2 C E TRUE 3 TRUE FALSE 4 762 FALSE 5 D value TRUE 6 1. Formula entered in the B2 cell is =ISTEXT("25"). As a result, the function returns TRUE as the supplied value is textual. 2. Formula entered in the B3 cell is =ISTEXT(A3). As a result, the function returns FALSE as the A3 cell contains a non-text value. 3. Formula entered in the B4 cell is =ISTEXT(A4). As a result, the function returns FALSE as the A4 cell contains contains a non-text value. 321 4. Formula entered in the B5 cell is =ISTEXT(A5). As a result, the function returns TRUE as the A5 cell contains a text value. 322 NA Returns the #N/A error which stands for "value is not available". Syntax =NA() Notes • Typing =NA() into a cell is an equivalent to directly entering the #N/A error value. Examples A 1 2 B C D E Data Result #N/A 3 Formula entered in the B2 cell is as follows =NA(). As a result, the function returns the #N/A error value. 323 Chapter 14 Reference functions 324 ADDRESS Returns a cell location in a worksheet based on specified row and column numbers. Syntax =ADDRESS(row, column, [absolute_relative_mode], [use_a1_notation], [sheet]) row — a row number of a cell being considered. column — a column number of a cell being considered. Column A is numbered 1. [absolute_relative_mode] (optional) — a reference type to be used. If the argument is omitted, 1 is set by default. The following options are available: • 1 is an absolute row and column (e.g. $A$1); • 2 is an absolute row and a relative column (e.g. A$1); • 3 is a relative row and an absolute column (e.g. $A1); • 4 is a relative row and column (e.g. A1). [use_a1_notation] (optional) — a reference style to be applied: A1 style (TRUE or omitted) or R1C1 style (FALSE). If the argument is omitted, TRUE is set by default. [sheet] (optional) — a sheet name in which a cell is located. By default, the argument is absent, and the current sheet is considered. Examples A 1 B C Data Result 2 $A$3 3 B$5 4 R4C3 5 $C2 6 D1 7 RC 8 325 D E 1. Formula entered in the B2 cell is =ADDRESS(3, 1). As a result, the function returns an absolute row and column of the cell at the intersection of row 3 and column 1, that is equal to $A$3. 2. Formula entered in the B3 cell is =ADDRESS(5, 2, 2). As a result, the function returns an absolute row and a relative column of the cell at the intersection of row 5 and column 2, that is equal to B$5. 3. Formula entered in the B4 cell is =ADDRESS(4, 3, , FALSE). As a result, the function returns the cell at the intersection of row 4 and column 3 in R1C1 style, that is equal to R4C3. 4. Formula entered in the B5 cell is =ADDRESS(2, 3, 3). As a result, the function returns a relative row and an absolute column of the cell at the intersection of row 2 and column 3, that is equal to $C2. 5. Formula entered in the B6 cell is =ADDRESS(1, 4, 4, TRUE). As a result, the function returns a relative row and column of the cell at the intersection of row 1 and column 4, that is equal to D1. 6. Formula entered in the B7 cell is =ADDRESS(0, 0, 4, FALSE). As a result, the function returns the cell at the intersection of row 0 and column 0 in R1C1 style, that is equal to RC. 326 AREAS Returns the number of areas in a reference or a range. An area is considered as a separate cell reference or a range of cells. Syntax =AREAS(reference) reference — a cell reference or a range of cells which can refer to multiple areas. Notes • To specify several areas in a single argument, enter ranges or references enclosed in double parentheses, e.g. =AREAS((A1:A5, G7, D5)). Examples A B C 1 Data Result 2 1 3 1 4 2 5 1 D E 6 1. Formula entered in the B2 cell is as follows =AREAS(A2). As a result, the function returns 1 as only one area is specified as a cell reference. 2. Formula entered in the B3 cell is as follows =AREAS(A2:A4). As a result, the function returns 1 as a range of cell is supplied to the formula. 3. Formula entered in the B4 cell is as follows =AREAS((A3:A5, C2)). As a result, the function returns 2 as a range of cells and a cell reference are considered as 2 areas. 4. Formula entered in the B5 cell is as follows =AREAS(INDIRECT("A5")). As a result, 327 the function counts the number of areas to which the INDIRECT function refers and returns 1. 328 CHOOSE Retrieves a value from a dataset based on its position number. Syntax =CHOOSE(index, choice1, [choice2, ...]) index — a number indicating a value position at which a value is to be found. choice1 — the first value in a dataset. It can be a number, a logical value, a cell reference, or a text value. [choice2, ...] (optional) — additional values among which to choose a value. Notes • If index is less than 1 or greater than the number of supplied values, CHOOSE returns the #VALUE! error. • The maximum number of the function arguments is limited to 255. Examples 1 A B C Data Result 2 Cherry Cherry 3 Melon 4 Apricot 5 Apple D E Apple 6 #VALUE! 6 1. Formula entered in the B2 cell is =CHOOSE(1, A2). As a result, the function returns the first value that is located in cell A2. 2. Formula entered in the B3 cell is =CHOOSE(3, A3, A4, A5). As a result, the function returns the third value from the supplied cell references. 3. Formula entered in the B4 cell is =CHOOSE(2, 7, 6, 8). As a result, the function returns the second value from the supplied numeric values, that is equal to 6. 329 4. Formula entered in the B5 cell is =CHOOSE(0, "One", "Two", "Three"). As a result, the function returns the #VALUE! error as the index number is less than 1. 330 COLUMN Returns a column number of a specified cell. Syntax =COLUMN([cell_reference]) [cell_reference] (optional) — a cell which column number is to be returned (column A is numbered 1). If the argument is omitted, the function defaults to the cell with the formula. Examples A B C 1 Data Result 2 2 3 1 D E 4 1. Formula entered in the B2 cell is =COLUMN(). As a result, the function returns a column number of the current cell, that is equal to 2. 2. Formula entered in the B3 cell is =COLUMN(A3). As a result, the function returns a column number of cell A3, that is equal to 1. 331 COLUMNS Returns the count of columns in a range or an array. Syntax =COLUMNS(range) range — a range or an array which column count is to be returned. Examples A B C 1 Data Result 2 2 3 3 D E 4 1. Formula entered in the B2 cell is =COLUMNS(A2:B3). As a result, the function returns the number of columns in the range, that is equal to 2. 2. Formula entered in the B3 cell is =COLUMNS({1, 2, 3; 4, 6, 5}). As a result, the function returns the number of columns in the supplied array of constants, that is equal to 3. 332 HLOOKUP Evaluates the first row of a range for a search value and returns a value which is located in a different row but in the same column. Syntax =HLOOKUP(search_key, range, index, [match_type]) search_key — a value for which to search in the first row of range. The value can be specified as a numeric or text value, or a cell reference. range — a range of cells to be considered for the search. index — a row number of the value to be returned. The first row in range is set to 1. [match_type] (optional) — a logical value that specifies whether to use an approximate (TRUE) or exact (FALSE) match. If the argument is omitted, TRUE is set by default. Notes • Uppercase and lowercase text values in search_key are considered as equivalent. • Wildcard characters enable you to filter a list of data based on a supplied condition and search for values by partial match. • If match_type is TRUE (or omitted), and no exact match is found, HLOOKUP returns the nearest smaller value of search_key. • If the index value is beyond the range considered for the search, HLOOKUP returns the #REF! error. Examples A B C D Price Quantity E 1 Data 2 Peaches 67 10 Peaches 3 Apricots 56 13 4 Bananas 89 31 Apricots 5 Mangoes 92 23 Bananas 6 Apples 34 17 #N/A 7 333 Result 31 1. Formula entered in the D2 cell is =HLOOKUP("sheet", A2:B5, 1, TRUE). As a result, the function searches for the "sheet" value in the first row of the A2:B5 range and returns its next lower value from the same row as the exact match is not found. 2. Formula entered in the D3 cell is =HLOOKUP(43, B2:C5, 3). As a result, the function searches for number 43 in the first row of the B2:C5 range and returns the nearest smaller number from row 3 as no exact match is found. 3. Formula entered in the D4 cell is =HLOOKUP("peaches", A2:C5, 2, TRUE). As a result, the function searches for the "peaches" value in the first row of the A2:C5 range and retrieves the value from row 2 of the same column. 4. Formula entered in the D5 cell is =HLOOKUP("??????s", A2:C5, 3, FALSE). As a result, the function searches for a 7-long character value ending with -s in the first row of the A2:C5 range and retrieves the value from row 3 of the same column. 5. Formula entered in the D6 cell is =HLOOKUP(47, A2:C5, 3, FALSE). As a result, the function searches for number 47 in the first row of the range and returns the #N/A error because no exact match is found. 334 HYPERLINK Creates a link in a cell of a worksheet. Syntax =HYPERLINK(url, [link_label]) url — an URL of a link address enclosed in quotation marks or a reference to a cell containing such an URL. [link_label] (optional) — a link text to display or a reference to a cell containing such text. If the argument is omitted, the url value is used by default. Examples 1 A B C Data Result 2 wiki 3 https://www.yandex.com D E 4 1. Formula entered in the B2 cell is =HYPERLINK("https://www.wikipedia.org", "wiki"). As a result, the function creates a link to the webpage. 2. Formula entered in the B3 cell is =HYPERLINK("https://www.yandex.com"). As a result, the function creates a link to the webpage. 335 INDEX Returns an element of an array or range, specified by its row and column position. Syntax =INDEX(area, row_num, [column_num], [range_num]) area—an array, a range, or a list of ranges from which to select an element. row_num—the row position of an element in the given area. [column_num] (optional)—the column position of an element in the given area. [range_num] (optional)—the range from which to select an element if area consists of multiple ranges. If the argument is omitted, the function sets it to 1. Notes • If you specify only row_num for area that has only one column, the function selects an element from this column. If you specify only row_num for area that has more than one row, the function returns the whole row you specified. • If you specify only column_num for area that has only one row, the function selects an element from this row. If you specify only column_num for area that has more than one column, the function returns the whole column you specified. • If you have an array with only one row, you can return one of its elements by specifying only row_num, which will be treated as the element position in the given row (see example #6). • If you leave both row_num and column_num unspecified, the function returns the whole range (array). • If the result of the function is an array, only the top left element is displayed. If the result is a range, the #VALUE! error is displayed, however you can resolve such a formula with implicit intersection (see 2.4.2). • row_num and column_num must not be greater than the actual number of rows and columns in area. Otherwise, the function returns the #REF! error. • If area contains multiple ranges, they must be enclosed in parentheses and separated by a comma. 336 Examples A B C D E 1 Data Amount Delivery Result 2 Checkers 43 03/01/2015 03/01/2015 3 Chess 89 06/01/2015 4 Cards 33 04/09/2015 09/28/2015 5 Billiard 18 09/28/2015 89 4 6 3 7 4 1. The formula in the D2 cell is =INDEX(A2:C5, 1, 3). The function selects a cell that is located in the second row of the first column and returns 03/01/2015. 2. The formula in the D3 cell is =INDEX(A2:C5, , 2). The result of the function is a reference to the B2:B5 range, but the editor resolves the error with implicit intersection and returns the content of the B3 cell. 3. The formula in the D4 cell is =INDEX((A2:C2, A4:C5), 2, 3, 2). The function selects the element that is located in the second range, on the second row of the third column. 4. The formula in the D5 cell is =INDEX({1,2;3,4}, 2, 2). The function selects the element that is located on the second row of the second column of the given array. 5. The formula in the D6 cell is =INDEX({1,2;3,4}, 2). The function returns the whole second row, but only the first element is displayed. 6. The formula in the D7 cell is =INDEX({1,2,3,4,5,6}, 4). The given array has only one row, so row_num is treated as the element position in the row. As a result, the function returns the fourth element in the given row. 337 INDIRECT Returns the content of the reference which can be a cell or a string. Syntax =INDIRECT(cell_reference_as_string, [is_A1_notation]) cell_reference_as_string — a cell reference or a string. [is_A1_notation] (optional) — a reference style to be applied: A1 style (TRUE or omitted) or R1C1 style (FALSE). If the argument is omitted, TRUE is used by default. Notes • If the cell_reference_as_string value refers to a different worksheet, the referenced worksheet must exist in an active workbook. Otherwise, INDIRECT returns the #REF! error. Examples A B C D 1 References Data Result 2 B2 25 E 25 3 4 #REF! 4 2 2 5 1. Formula entered in the C2 cell is =INDIRECT(A2). As a result, the function returns the value from cell B2 as cell A2 contains a reference to cell B2. 2. Formula entered in the C3 cell is =INDIRECT("Sheet2!A2"). As a result, the function refers to cell A2 in another worksheet, and returns the #REF! error as the worksheet does not exist in the current workbook. 3. Formula entered in the C4 cell is =INDIRECT("B"&B3). As a result, the function joins letter B with the value in cell B3, that is 4, and returns the value from cell B4. 338 LOOKUP Looks through a row or a column for a key and returns the cell value in a result range located in the same position as a search row or column. The function allows searching across one row or column or a number of them. Based on this, the function distinguishes two search methods: a vector or array search. Notes • Text values supplied as a search key must be enclosed in double quotation marks, e.g. "value". • If a search range or array contains duplicate values, LOOKUP matches the first occurrence. • Uppercase and lowercase text values are considered as equivalent. • If an exact match is not found, the LOOKUP function returns the nearest smaller value. • If an array search method is applied, a search key must be present in the first column of an array or a range. • If LOOKUP evaluates multiple rows and columns for a key, the result is retrieved from the last column or row. • A vector search method assumes the supplied ranges are equal in size. Otherwise, LOOKUP returns the #N/A error value. Vector Search Syntax =LOOKUP(search_key, search_range, [result_range]) search_key — a value to be searched for in a column or a row of search_range. The value can be specified as a numeric or text value, logical expression, and cell reference. search_range — a single row or column to look through for search_key. [result_range] (optional) — a range from which to return the result. 339 Examples A 1 Data B C Amount Supplier D E Result 2 Apples 34 Tom 56 3 Mangoes 56 Peter Apricots 4 Apricots 78 Garry 78 5 Grapefruits 23 Michael 6 Mangoes 44 Peter #N/A 34 7 1. Formula entered in the D2 cell is =LOOKUP(A3, A2:A6, B2:B6). As a result, the function searches across column A for the "Mangoes" value (cell A3) and returns its corresponding value from column B. 2. Formula entered in the D3 cell is =LOOKUP(78, B2:B6, A2:A6). As a result, the function searches for number 78 in column B and returns its corresponding value from column A. 3. Formula entered in the D4 cell is =LOOKUP("crop", A2:A6, B2:B6). As a result, the function searches for the "crop" value in column A, picks up the nearest smaller value as the specified value is not available and returns the corresponding value from column B. 4. Formula entered in the D5 cell is =LOOKUP("act", A2:A6, B2:B6). As a result, the function returns the #N/A error as it fails to find both the "act" value and its nearest smaller value in column A. 5. Formula entered in the D6 cell is =LOOKUP(41, B2:B6). As a result, the function returns the nearest smaller value of 41 because the exact match is not available in column B. Array Search Syntax =LOOKUP(search_key, search_result_array) search_key — a value to be searched in an array or a range. The value can be specified as a numeric or text value, logical expression, cell reference. 340 search_result_array — a range of cells to be tested against search_key. Examples A B C 1 Data 2 Apples 24 Garry 3 Mangoes 75 Peter 4 Apricots 57 Michael D E Amount Supplier Result 57 Peter 75 5 1. Formula entered in the D2 cell is =LOOKUP(A4, A2:B4). As a result, the function searches across the first column of A2:B4 range for the "Apricots" value (cell A4) and returns its corresponding value from column B. 2. Formula entered in the D3 cell is =LOOKUP(75, B2:C4). As a result, the function searches for number 75 in the first column of the B2:C4 range and returns its corresponding value from column C. 3. Formula entered in the D4 cell is =LOOKUP("row", A2:B4). As a result, the function searches for the "row" value in the first column of the A2:B4 range, picks up the nearest smaller value (as the search key is not available) and returns the corresponding value from column B. 341 MATCH Allows finding a specified item in the defined range of cells by a desired search type. The function returns the item index (i.e.: a position number of the item in an array), not the item itself. Syntax MATCH(search_key, range, [search_type]) search_key — the specified item value you want to match in the defined range. Possible values are a number, a string, a number as a string, a boolean, an error or an empty value. • If it is a number, the number format is ignored in a range. • If all numbers are specified as a string, they are detected as numbers with format. • While searching, first, the format is considered, then the number itself. • Matching by a string value is provided by the sign weight. range — the range (single dimension array: horizontal or vertical) you define to search for the specified item. It can be sorted in any manner, either ascending or descending order, or unsorted. [search_type] (optional) — the search type you want to use to find the specified number in the defined range. Possible values are numbers. If the argument is omitted, 1 is set by default. • Any positive number from the (0; +∞) range is casted to 1. • A zero or empty value is casted to 0. • Any negative number from the (-∞; 0) range is casted to -1. • Any string value provokes the #VALUE! error. Notes • The search direction for matching elements is considered from left to right (or from top to bottom) if it is 0, 1 or omitted. Otherwise, the search direction for matching elements is considered from right to left (or from bottom to top). 342 • When search_type = 1 or omitted, MATCH searches for and then returns the last matched element found in the defined range that is equal to or less than the search_key value. First, the function algorithm searches for the equal element in the range. If a number is presented as a string, it is casted to a number, and the function returns an index of the last value (a search direction is considered from left to right or from top to bottom), first, matched by format, and then equal to or less than the number value. • When search_type = 0, MATCH returns the first matched element which is equal to the search_key value; otherwise, the #N/A error is returned. The wildcard symbols search is supported. If a number is presented as a string, it is not casted to a number, and matching is provided by the sign comparison by weight. • When search_type = -1, MATCH returns an index of the last matched element found in the defined range that is equal to or greater than the search_key value. First, the function algorithm searches for the equal element in the range. If a number is presented as a string, it is casted to a number, and the function returns an index of the last value (a search direction is considered from right to left or from bottom to top), first, matched by format, and then equal to or greater than the number value. 343 Examples A 1 Index B C D Item ID Item Price 2 1 1030 apple 23 3 2 1032 grapefruit 40 4 3 1033 mango 20 5 4 1036 peach 17 E 6 7 8 Item ID Result 9 1034 3 10 1034 3 11 1036 4 12 13 14 Item ID 15 1034 16 1036 Result #N/A 4 17 18 19 Item Result 20 mango 3 21 peach 4 22 1. Formula entered in the C9 cell is as follows =MATCH(A9, B2:B5, 1). As a result, the function searches from top to bottom and then returns an index of the last matched element found in the defined range. As there is no exact value in the specified range, the last matched element is less than the search_key value, and its index is 3. 2. Formula entered in the C10 cell is as follows =MATCH(A10, B2:B5). As a result, the function searches from top to bottom and then returns an index of the last matched element found in the defined range. As there is no exact value in the specified range, the last matched element is less than the search_key value, and its index is 3. 3. Formula entered in the C11 cell is as follows =MATCH(A11, B2:B5, 1). As a result, the function searches from top to bottom and then returns an index of the last matched element found in the defined range. The index is equal to 4. 344 4. Formula entered in the C15 cell is as follows =MATCH(A15, B2:B5, 0). As a result, the function searches from top to bottom and then returns the #N/A error as there is no matched element in the defined range which is equal to the search_key value. 5. Formula entered in the C16 cell is as follows =MATCH(A16, B2:B5, 0). As a result, the function searches from top to bottom and then returns an index of the the first matched element found in the defined range. The index is equal to 4. 6. Formula entered in the C20 cell is as follows =MATCH("mango", C2:C5, 0). As a result, the function searches from top to bottom and then returns an index of the the first matched element found in the defined range. The index is equal to 3. 7. Formula entered in the C21 cell is as follows =MATCH("peach", C2:C5, 0). As a result, the function searches from top to bottom and then returns an index of the first matched element found in the defined range. The index is equal to 4. 345 OFFSET Returns a cell or a range of cells shifted by a specified number of rows and columns from the initial cell reference. Syntax =OFFSET(cell_reference, offset_rows, offset_columns, [height], [width]) cell_reference — a starting point from which to count the offset rows and columns. offset_rows — the number of rows by which to shift. offset_columns — the number of columns by which to shift. [height] (optional) — the number of rows in the output range. If the argument is omitted, it defaults to the size of cell_reference. [width] (optional) — the number of columns in the output range. If the argument is omitted, it defaults to the size of cell_reference. Notes • When shifting, OFFSET does not consider the first cell reference specified in cell_reference. • The offset_rows can be specified both as a negative and positive number. Specifying a positive value makes a reference move a given number of rows down from the starting cell reference; a negative value assumes a reference to be shifted by a specified number of rows up. • The offset_columns argument must be an integer either negative or positive. A negative value enables a reference to move to the left-hand side of the spreadsheet, a positive value – to the right-hand side. • If either height or width equals 0, OFFSET returns the #REF! error value. • If height is a positive number, a range is shifted by a specified number of rows down starting from the cell_reference position. If the argument is specified as a negative value, a range moves up. • If width is a positive number, a range is shifted by a specified number of columns to the right-hand side of the spreadsheet. If the argument is specified as a negative value, a range moves to the left-hand side. 346 • If the position of the output range goes beyond the edge of the worksheet, OFFSET returns the #REF! error. Examples A B C D 1 Data Amount Result 2 Apples 34 3 Bananas 67 Oranges 4 Oranges 90 34 5 Mangoes 45 45 E 90 6 1. Formula entered in the C2 cell is as follows =OFFSET(A2, 2, 1). Starting with cell A2, the function shifts 2 rows down and 1 column to the right and returns the value from cell B4. 2. Formula entered in the C3 cell is as follows =OFFSET(B2, 2, -1). Starting with cell B2, the function shifts 2 rows down and 1 column to the left and returns the value from cell A4. 3. Formula entered in the C4 cell is as follows =OFFSET(A4, -2, 1). Starting with cell A4, the function shifts 2 rows up and 1 column to the right and returns the value from cell B2. 4. Formula entered in the C5 cell is as follows =OFFSET(A4, -2, 1, 4). Starting with cell A4, the function shifts 2 rows up, 1 column to the right and 4 cells down cell B2 and returns the value from cell B5. 347 ROW Returns a number of the row where a cell is specified. Syntax =ROW([cell_reference]) [cell_reference] (optional) — a cell which row number to be returned. If the argument is omitted, the function defaults to the cell with the formula. Notes • If cell_reference is specified as a vertical range and the formula intersects with the range, ROW returns a row number of the cell at the intersection. In case the formula does not intersect with the range, the calculation results in the #VALUE! error. • ROW does not support arrays in the calculation. Examples A 1 B C D E Data Result 2 23 2 3 16 3 4 64 4 5 1. Formula entered in the B2 cell is as follows =ROW(A2). As a result, the function returns a row number of cell A2. 2. Formula entered in the B3 cell is as follows =ROW(). As a result, the function returns a row number of the current cell. 3. Formula entered in the B4 cell is as follows =ROW(A2:A4). As a result, the function returns a row number of cell B4 which intersects with the A2:A4 range. 348 ROWS Returns the count of rows in a range or an array. Syntax =ROWS(range) range — a range or an array which row count is to be returned. Examples A B C 1 Data Result 2 3 3 1 4 2 D E 5 1. Formula entered in the B2 cell is as follows =ROWS({1, 2, 6; 4, 5, 8; 6, 7, 34}). As a result, the function returns the count of rows in the three-dimensional array. 2. Formula entered in the B3 cell is as follows =ROWS({14.32,"value"}). As a result, the function returns the count of rows in the array. 3. Formula entered in the B4 cell is as follows =ROWS(A2:A3). As a result, the function returns the count of rows in the range. 349 VLOOKUP Searches down the first column of a range for the first matching key and returns the corresponding value from another column. Syntax =VLOOKUP(search_key, range, index, [match_type]) search_key — a value for which to search. range — a range to be considered for the search. The first column in a given range must contain search_key. index — a column number of the value to be returned. The first column in range is numbered 1. [match_type] (optional) — a logical value that specifies whether to use an approximate (TRUE) or exact (FALSE) match. If the argument is omitted, TRUE is set by default. Notes • If match_type is TRUE (or omitted) and no exact match is found, VLOOKUP returns the nearest smaller entry of search_key. • If a search value is not found in the first column of range, VLOOKUP returns the #N/A error value. • If a value in index is greater than the actual number of columns in a range, VLOOKUP returns the #REF! error. • Uppercase and lowercase text values in search_key are considered as equivalent. • Wildcard characters allow you to filter a list of data based on a supplied condition and search for a partial match. 350 Examples A 1 Data B C D E Amount Supplier Result 2 Apples 68 Tom 59 3 Mangoes 56 Peter Jerry 4 Grapefruits 87 Garry Tom 5 Bananas 59 Michael 6 Peaches 67 Mark Peter 7 Apricots 82 Jerry #N/A 56 8 1. Formula entered in the D2 cell is as follows =VLOOKUP("bananas", A2:B5, 2). As a result, the function searches for the "banana" value in the A2:A5 range and returns the corresponding value from column B. 2. Formula entered in the D3 cell is as follows =VLOOKUP(85, B2:C7, 2). As a result, the function searches for number 85 in column B. As number 85 is not available, the function finds the nearest smaller number, that is 82, and returns the corresponding value from column C. 3. Formula entered in the D4 cell is as follows =VLOOKUP(68, B2:C5, 2, FALSE). As a result, the function searches for number 68 in column B and retrieves the corresponding value from column C. 4. Formula entered in the D5 cell is as follows =VLOOKUP("m*", A2:C5, 2, FALSE). As a result, the function searches for the value in column A starting with letter M and retrieves the corresponding value from column B. 5. Formula entered in the D6 cell is as follows =VLOOKUP("??????s", A2:C5, 3, FALSE). As a result, the function searches in column A for a 7-character long value ending with -s, that is "Mangoes", and retrieves the corresponding value from column C. 6. Formula entered in the D7 cell is as follows =VLOOKUP(59, A2:C5, 2, FALSE). As a result, the function searches in column A for number 59 which is not available in the list. 351 Chapter 15 Engineering functions 352 COMPLEX Creates a complex number based on specified real and imaginary components. Syntax =COMPLEX(real_number, imaginary_number, [suffix]) real_number — a number which represents a real component of a complex number. imaginary_number — a number which represents an imaginary component of a complex number. [suffix] (optional) — a character indicating which suffix is to be used: "i" or "j". If the argument is omitted, "i" is used by default. Notes • Specifying a text suffix is case-sensitive. If the capital "I" or "J" is entered to suffix, the function results in the #VALUE! error. • The function supports numbers presented as strings, e.g. "12". The resulted value is recognised as a number. • Logical values are casted to numbers: TRUE – to 1 and FALSE – to 0 (zero). Examples 1 A B C Data Result 2 -5-8i 3 9 9-24i 4 -24 34+91j 5 D E FALSE -8i 6 1. Formula entered in the B2 cell is =COMPLEX(-5, -8). As a result, the function creates the -5-8i complex number based on the specified real and imaginary components. 353 2. Formula entered in the B3 cell is =COMPLEX(A3, A4, "i"). As a result, the function creates the 9-24i complex number based on the real and imaginary components specified in cells A3 and A4, and the i suffix. 3. Formula entered in the B4 cell is =COMPLEX(34, 91, "j"). As a result, the function creates the 34+91j complex number based on the supplied real and imaginary components, and the j suffix. 4. Formula entered in the B5 cell is =COMPLEX(A5, -8). As a result, the function creates the -8i complex number based on the following values: the real component is 0 (FALSE is casted to 0); the imaginary component is -8. 354 IMABS Returns the absolute value of a complex number. Syntax =IMABS(complex_number) complex_number — a complex number presented as a string for which the absolute value is to be returned. Examples 1 A B C Data Result 2 9.433981132 3 7+8i 10.630145813 4 4.472135955 D E 5 1. Formula entered in the B2 cell is =IMABS("-5-8j"). As a result, the function returns the absolute value of the -5-8j complex number, that is equal to 9.433981132. 2. Formula entered in the B3 cell is =IMABS(A3). As a result, the function returns the absolute value of the 7+8i complex number, that is equal to 10.630145813. 3. Formula entered in the B4 cell is =IMABS(COMPLEX(4, -2)). As a result, the function returns the absolute value of the 4-2i complex number, that is equal to 4.472135955. 355 Appendix A Alphabetic index ABS ACOS ACOSH ACOT ADDRESS AND AREAS ASC ASIN ATAN ATAN2 ATANH AVERAGE CELL CHOOSE CLEAN CODE COLUMN COLUMNS COMPLEX CONCATENATE Conversion functions: JIS and DBCS COSH COTH COUNT COUNTA COUNTBLANK 356 COUNTIF COUNTIFS COUPPCD CSC CSCH DATE DATEVALUE DAY DEGREES DOLLARDE DOLLARFR DSUM EDATE EOMONTH EXACT EXP F.DIST.RT F.DIST FACTDOUBLE FALSE FIND and FINDB FISHER HLOOKUP HOUR HYPERLINK IF IFERROR IFNA IMABS INDEX INDIRECT INFO INT IRR ISBLANK ISERR ISERROR ISEVEN ISLOGICAL ISNA 357 ISNUMBER ISODD ISOWEEKNUM ISREF ISTEXT LARGE LEFT and LEFTB LEN and LENB LINEST LN LOG LOG10 LOOKUP LOWER MATCH MAX MID and MIDB MIN MINUTE MONTH NA NORM.DIST NOW NPV OFFSET OR PI PMT POWER PRODUCT PROPER PV QUOTIENT RAND RANK.EQ RIGHT and RIGHTB ROUND ROUNDDOWN ROUNDUP ROW 358 ROWS SEARCH and SEARCHB SEC SECH SINH SMALL SQRT SQRTPI STDEV.S SUBTOTAL SUBSTITUTE SUM SUMIF SUMIFS SUMPRODUCT SUMSQ SWITCH TANH TEXT TODAY TRIM TRUE UNICODE UPPER VAR VARA VARPA VLOOKUP YEAR 359