Microsoft Excel Essentials for Pharmacy Informatics

Introduction

This resource provides a list of useful MS Excel concepts and examples that have come up over the years for various data challenges. These are real use cases that have occurred in my personal pharmacy informatics practice.

1. VLOOKUP

Description: The VLOOKUP is an essential tool for data handling, particularly in the finicky world of reporting, where it is not uncommon to get data extracts that do not have all the columns necessary. Getting 100% of what you are looking for from a report writer is not practical or always possible. This is not an uncommon issue in the health care IT arena. Thus, combining data from a separate Excel that has the necessary column(s) can be a lifesaver. That is if there is a matching column that can tie together data from the other Excel sheet/workbook/list exactly. I effectively call this functionality a “poor person’s” query. And although it does the trick, a VLOOKUP is much more resource intensive than joining tables in a real relational database.

Example: This simple example works for any matching of one list/sheet/workbook to another and pulling any available values from the specified column.

VLOOKUP Figure
Excel VLOOKUP formula example showing how to match two pharmacy data lists

Download: VLOOKUP sample file (.xlsx)

2. XLOOKUP

Description: An XLOOKUP is very similar to VLOOKUP in the way that a cell from one list/sheet/workbook is matching to a second list/sheet/workbook’s cell, and then pulls in the value from a column in the second list which is aligned to the row from the matching cell. The XLOOKUP is in principle an even simpler VLOOKUP, although I find it more effective in doing more advanced comparisons, as provided in the example below.

Example: An example use case where I have found the XLOOKUP useful is when I am determining if a particular item (like a prescription fill) was filled within a date window (like an authorization date range). The figure and sample show two separate tables and the use of XLOOKUP to determine if the date of the prescription (table 1) was between the date range in the rows listed in table 2.

XLOOKUP Figure
Excel XLOOKUP example checking if a prescription fill date falls within an authorization window

Download: XLOOKUP sample file (.xlsx)

3. Convert Text to Columns (Carriage Return Delimiter)

Description: In situations where a record has multiple responses of data in columns that are not broken into multiple rows, rather are stacked in one cell via a carriage return (i.e. delimited by Alt+enter).

Example: The figure below displays medication mixture records and the available multiple drug ingredients. In this example, the multiple ingredients are combined in one row, delimited by a carriage return (or defined by Excel as Alt+enter).

Example sheet
Dataset showing multiple drug ingredients combined in one cell using carriage returns

To split these combined values on the same row using “Text to Columns”, first highlight the column, select “Text to Columns” under Data in the Toolbar.

Text to Columns button in Excel Data ribbon

Select the “Delimited” option in the Text to Columns wizard.

Text to Columns Wizard Step 1 selecting Delimited

In the next step of the wizard, select and press Ctrl+j in the "Other" option box. Although it does not appear to display much in the field, the process does work.

Text to Columns Wizard Step 2 using Ctrl+J for carriage return delimiter

In the final step, select finish to complete the parsing. Do note that separating these values will require empty real estate next to this column, otherwise there will be a warning stating that you will overwrite populated data.

Animation showing the process of splitting text to columns using carriage returns

Download: Multi-response sample file (.xlsx)

4. Fill in Blank Cells

Description: In situations where a record has multiple responses of data in columns that break into multiple rows, there are gaps of blank cells in the other columns when exporting data. This makes filtering and handling the data challenging.

Example: This example is essentially the reverse problem of the previous example of combining multiple responses in one row. In this example, the multiple responses are split out in separate rows, but the other single response values do not fill the additional rows.

Example sheet
Excel dataset showing blank cells in rows that need to be filled

To fill in the blanks, there are three simple steps:

  1. Select the impacted column.
  2. Go to Toolbar -> Home -> Find & Select -> Go to Special -> Blanks.
  3. All of the blank cells become highlighted. Touch nothing but the = key and the up arrow. Follow that with Ctrl+Enter and all blanks will populate with the value of the cell above.
Animation demonstrating how to batch fill blank cells in Excel

Download: Multi-response sample file (.xlsx)

5. INDEX Function

Description: Transpose columns listed vertically to horizontally using the INDEX function.

Example: Here is an extract of a list of medications that lists the columns vertically down a single column. This is not a very useful way to work the data! The figure and sample provide a detailed use of the INDEX function to transpose the columns horizontally.

Example sheet
Vertical list of medication data before transposition

Illustration of the equation:

Explanation of the INDEX formula logic

GIF of steps:

Animation showing the INDEX function transposing data from vertical to horizontal

Download: Index function sample file (.xlsx)