Accounting Analytics: An Integrated Approach
Part II of V: Accounting Analytics with Excel
Chapter 2 of 5 in this Part
Table 5.1 · Text functions used for data preparation
| Function | What it returns | Example with a Charles River value |
|---|---|---|
LEFT(text, n) |
The first n characters | LEFT("FUR-DSK-0075",3) returns FUR |
MID(text, start, n) |
n characters starting at a position | MID("FUR-DSK-0075",5,3) returns DSK |
RIGHT(text, n) |
The last n characters | RIGHT("SI-2025-007947",6) returns 007947 |
LEN(text) |
The number of characters | LEN("FUR-DSK-0075") returns 12 |
FIND(find, text) |
The position of one text inside another | FIND("-","FUR-DSK-0075") returns 4 |
Table 5.1 · Text functions used for data preparation
| Function | What it returns | Example with a Charles River value |
|---|---|---|
TRIM(text) |
The text without leading, trailing, or repeated spaces | Removes stray spaces from an imported name |
CLEAN(text) |
The text without the basic non-printing control characters | Removes line breaks copied in from another system |
SUBSTITUTE(text, old, new) |
The text with one string replaced by another | Replaces “Street” with “St” to standardize addresses |
UPPER, LOWER, PROPER |
The text in capitals, lower case, or with each word capitalized | UPPER("Smith Ltd") returns SMITH LTD |
EXACT(text1, text2) |
TRUE if the two texts are identical, including their case | EXACT("LLC","Llc") returns FALSE |
VALUE(text) |
The number that a text value represents | Converts "007947" to 7947 |
=LEN([@CustomerName])=LEN(TRIM([@CustomerName])) is TRUE for a name with no stray spacesROUNDUP(MONTH([@InvoiceDate])/3,0)Table 5.2 · Logical functions used for data preparation
| Function | What it returns | Example |
|---|---|---|
IF(test, if_true, if_false) |
One of two values, depending on a test | Label invoices with extended payment terms |
IFS(test1, value1, ...) |
The value paired with the first true test | Group payment terms into bands |
AND(test1, test2, ...) |
TRUE only if every test is true | Check each part of an item code |
Table 5.2 · Logical functions used for data preparation
| Function | What it returns | Example |
|---|---|---|
OR(test1, test2, ...) |
TRUE if at least one test is true | Check that terms are one of the standard values |
NOT(test) |
The opposite of the test | Flag the lines that are not Furniture |
IFERROR(value, if_error) |
The value, or a substitute if the value is an error | Return “No match” when a lookup fails |
Which function does each task?
Check that:
Table 5.4 · Lookup functions compared
| Feature | VLOOKUP | INDEX and MATCH | XLOOKUP |
|---|---|---|---|
| Where the key can be | Only in the first column of the range | In any column | In any column |
| How the return column is chosen | By its number in the range | By reference to the column | By reference to the column |
| Effect of inserting or deleting columns | Can return the wrong column | Adjusts, unless a referenced column is deleted | Adjusts, unless a referenced column is deleted |
| Match when the match argument is left out | Approximate; FALSE asks for an exact match | Approximate; 0 asks for an exact match | Exact |
| When the key is not found, in an exact match | #N/A | #N/A | #N/A, or a value you supply |
| Availability | All versions of Excel | All versions of Excel | Microsoft 365, Excel 2024, and Excel 2021 |
Look up or summarize?
Check that:
Missing, meaningful or invalid?
Table 5.5 · Join kinds in Power Query merges
| Join kind | Rows in the result | Accounting use |
|---|---|---|
| Left outer | Every row of the first query, with the matching rows of the second | Adding invoice and item details to every invoice line |
| Inner | Only the rows that match in both queries | Keeping only lines whose item appears in a filtered item list |
| Full outer | Every row of both queries, matched where possible | Comparing two lists, such as a sub-ledger and a ledger extract |
| Left anti | Only the rows of the first query that have no match in the second | Finding orphaned records, such as lines whose item is missing |
Date.Year([InvoiceDate]), Date.QuarterOfYear([InvoiceDate])Text.Middle counts from zero, so the product type starts at 4, not 5Table 5.6 · Custom columns for the InvoiceLines query
| New column name | Custom column formula |
|---|---|
FiscalYear |
Date.Year([InvoiceDate]) |
FiscalQuarter |
Date.QuarterOfYear([InvoiceDate]) |
Period |
Text.From([FiscalYear]) & "-Q" & Text.From([FiscalQuarter]) |
ProductType |
Text.Middle([ItemCode], 4, 3) |
WholeQuantity |
[Quantity] = Number.RoundDown([Quantity]) |
Check that:
As-of date · Custom column · Data preparation · Fiscal period · INDEX and MATCH · Join kind · Left outer join · Logical function · Lookup function · Match key · Meaningful blank · Merge · Reference query · Text function · Validity check · XLOOKUP
Next: Chapter 6: Descriptive and Diagnostic Analytics in Excel
These slides accompany Accounting Analytics: An Integrated Approach, licensed under CC BY-SA 4.0. Every figure and table comes from the chapter:
https://aa.accountinganalyticshub.com/chapters/05-data-preparation/chapter.html
Chapter 5 · Data Preparation and Cleaning in Excel