Excel and Cognos

Excel and Cognos

Excel & Cognos Designed by Jason Wagner, Course Web Programmer, Office of e-Learning ZPRELIMINARY INFORMATION ...

493KB Sizes 5 Downloads 26 Views

Excel & Cognos

Designed by Jason Wagner, Course Web Programmer, Office of e-Learning

ZPRELIMINARY INFORMATION ......................................................................................................1   LOADING THE INITIAL REPORT .......................................................................................................1   OUR EXAMPLE ...................................................................................................................................2   DEFINED NAMES ...............................................................................................................................2   BUILDING THE DASHBOARD: THE EASY (BUT NOT RECOMMENDED) WAY .............................3   VLOOKUP ...........................................................................................................................................4   BUILDING THE DASHBOARD: THE RIGHT WAY WITH VLOOKUP ...............................................5   UPDATING THE REPORT ..................................................................................................................6   PROTECTING SPREADSHEETS ..........................................................................................................6  

PRELIMINARY INFORMATION This guide is primarily based upon Excel 2013. Most of this guide will apply to Excel 2007 and Excel 2010. However, some buttons may be located in different places, appearance may be different, etc. Although the title of this training was Excel and Cognos, this works for any system that exports data/reports in a text-delimited format. The most popular file is a CSV (comma separated value) file, but often also includes tabdelimited files as well. Although it may sound like a joke, you actually cannot import an Excel file using this method.

LOADING THE INITIAL REPORT Before we begin working with the data, we must create a data link to the report. If you have a CSV file that is updated, you can dynamically link to that file. To do this, go to the Data ribbon, in the Get External Data group, select From Text.

Then, locate the initial version of your data file, and click Open. On Step 1 of the Text Import Wizard, leave Delimited selected. If applicable, check the box for My data has headers. Click Next. On Step 2, if you are using a CSV file, change Tab to Comma. Hit Next. Finally, on Step 3, click Finish. On the Import Data dialog, first check Add this data to the Data Model leave Table selected for how you want to view the data. For where you want to put the data, select New worksheet. Click OK.

Excel & Cognos | Page 1

You’ll notice a new worksheet (tab) appears at the bottom of the screen, which will likely just be called Sheet2. You may want to rename it to something more memorable, like ImportedData. You will also want to use a more memorable name for your table. To rename this, click anywhere inside the table. Then, under Table Tools, select the Design menu. On the left side of the toolbar will be an option for Table Name. You should call this something simple, like MyData.

OUR EXAMPLE For our example, we are going to use reports from Cognos that are used to track undergraduate revenue for the summer semester. The report contains three columns: 1. 2. 3.

The subject code of the course(s) offered (example: BIO, MTH, etc.) The number of credit hours registered within that subject code The number of billable credit hours registered within that subject code.

For this example, we want to determine the amount of tuition revenue earned for each subject code. Our dashboard should show each subject code, the number of billable credit hours, and the tuition revenue earned (billable credit hours X tuition rate). To simplify things, the tuition rate for all courses will be $495 per credit.

DEFINED NAMES Defined names make it easy to store variables to bring them back later. We could store it in a cell and reference it, but that can make things complicated by requiring absolute cell references. We will use a defined name to store the tuition rate to make it easier to both write our formulas, and update if the rate were to change next year (or sometime after). Under the Formulas ribbon, select Define Name. Under Name, enter the name for this value that you want to remember at a later time. Be sure to leave the Scope on Workbook. You may, optionally, add a Comment to remind you what this is for later. Under Refers to, you can either use a cell reference (which will, by default, be filled in with whatever your cursor had highlighted when you selected Define Name from the toolbar. You can also enter a value, such as a number, in this cell. When you are finished, click OK.

Excel & Cognos | Page 2

Now, you can enter whatever you entered as the name in any formula. To change this later, go back to the Formulas ribbon, and select Name Manager. You can click on the row for the name you had entered, and click Edit….

BUILDING THE DASHBOARD: THE EASY (BUT NOT RECOMMENDED) WAY First, we are going to begin to build the structure of our dashboard, which will be the same whether we do this “The Easy Way” or “The Right Way.” In our dashboard, we are going to have the course subject code in Column A, the number of billable credit hours (which we’ll load from our report) in Column B, and the tuition revenue in Column C. Add these headings into the first row in the respective columns. Next, we will begin to add the subject codes, starting in Cell A2, and going down Column A. Then, in the tuition revenue column, we will put the formula for the first subject code’s tuition revenue in the first row. This will be the billable credit hours multiplied by the tuition rate. The billable credit hours will be in Cell B2. We defined the tuition rate as a Defined Name in Tuition. Thus, our formula in Cell C2 will be =B2 * Tuition. Because we actually haven’t loaded the data from our imported file yet, this will come out to 0. Replicate this formula throughout the rest of the rows of the dashboard. This column should also be formatted as money. So far, our spreadsheet should look like this:

Next, we just need to create a formula for the billable credit hours for ABBA that is a reference to its corresponding billable credit hours in the data that we imported, with no other calculations. In our ImportedData worksheet, the billable credit hours for ABBA is stored in cell C2. Thus, we need to make the formula for cell B2 on our dashboard =ImportedData!C2. WARNING: Do not click on Cell C2 in the table! Some versions of Excel will use a different type of reference because it is inside a table, which will not work for what we are doing. In this case, because the order of the subjects in our dashboard is the same as the order of the subjects in our imported report, we can simply replicate the formula down. Be sure to double check this if you use this method in the future to be sure that they all line up to the proper row.

Excel & Cognos | Page 3

Our dashboard should now look like this:

BUT THIS WORKS – SO WHY IS THIS NOT “RECOMMENDED”? The reason why this is not recommended is it is dependent upon the data for each item to be located in a specific cell. For example, suppose, after we build our initial report, they add a course like AS 101, which would be the first AS course added to the schedule. This would be added to the file in Row 6. That would throw all of the records that follow off by one row. Our dashboard would then report that the enrollment information for CHM as the enrollment for BIO. Thus, we need a different way of loading this information, which we can do using the VLOOKUP function.

VLOOKUP In order to protect against the possibility of additional records changing which row number the records we are looking for are located within, we will rely on the VLOOKUP function to help us locate the record instead of a particular row. VLOOKUP takes four arguments: • •





The value that you are attempting to locate in the table (In this case, it would be the subject code.) The name of the table (which we defined when we imported the initial data file) that contains the values we are returning (You can also use a range of cells instead, but be sure to use absolute cell referencing when replicating the formula.) The column number of the table in the previous argument that we want to return (Unlike most things in Excel, in which we wanted to use the letter of the column, we simply count columns from left to right to determine this number.) Whether we want to do a range lookup (value: TRUE) or an exact value search (value: FALSE). (In this case, we will use an exact value lookup, because we want to match the word we are using exactly.)

For example, in our case, suppose we want to find the number of billable credit hours (column 3) for the CS courses in our table (MyData). Then our formula would be: =VLOOKUP("CS", MyData, 3, FALSE).

Excel & Cognos | Page 4

As mentioned above, we want to do an exact value lookup, as opposed to a range lookup. A range lookup would be used when you are searching for where something would fall in a particular range. For example, in courses at Wilkes, there are grading scales defined in the course syllabus that list 90-100 is a 4.0, 85-89.99 is a 3.5, 80-84.99 is a 3.0, and so on. If we were doing an exact value lookup, that would mean we would need to have literally thousands of records in our lookup table for every possible value. For example, you would need an 85.0, 85.01, 85.02, etc. Range lookups allow you to create a lookup table that says any value that falls in a certain range would be assigned a particular value. However, as mentioned, we will be using an exact value lookup. Using a range lookup could produce different – and more importantly, inaccurate – results.

BUILDING THE DASHBOARD: THE RIGHT WAY WITH VLOOKUP To build our dashboard “the right way,” we are going to take the dashboard we used above when we used data by referencing, and simply change the cells with these references to use VLOOKUP instead. If we go to the first row for ABBA, delete the reference to =ImportedData!C2. Using VLOOKUP, let’s think about what our arguments will be: •

• • •

What is the value we are attempting to lookup? In this case, it is ABBA. However, we want to create a formula here that is easily replicable so we don’t have to change every row of our dashboard. So instead, we are going to reference the cell that has ABBA in it, and use A2. What is the name of the table that contains the values we are returning? In this case, it is MyData. What column number of the table do we want to return? Billable Credit Hours is the third column, so we will use 3. Are we doing a range search or an exact value search? We are doing an exact value search, so we are going to use FALSE.

This, our formula in Cell B2 should be =VLOOKUP(A2, MyData, 3, FALSE). We should be able to replicate this formula through the rest of our dashboard. Our dashboard should look like this:

Excel & Cognos | Page 5

While this provides the same data as we saw above, we can see it is much more reliable in case we encounter the scenario described above. Note that, if a value in our column is not in the table we imported, it will return #N/A as an error message.

UPDATING THE REPORT Now, suppose some time has passed and you have rerun your report. To do this, go to the Data ribbon and select Refresh All. Then, locate the new version of your data file, and click Open. The data in the file will import. This will update the dashboard you created with the appropriate information.

PROTECTING SPREADSHEETS Before we finish up, we probably want to make sure people don’t edit our spreadsheet. To do this, we can simply go to the Review ribbon, and in the Changes group, select Protect Sheet. This will stop people from editing our formulas, and potentially break the dashboard we built. WARNING: Only protect the sheet with the dashboard. If you protect the sheet that contains the data that is being imported/refreshed, it will not update the next time you refresh it and attempt to load a new spreadsheet.

Excel & Cognos | Page 6