AGB 260: Agribusiness Information Technology Importing Data, Managing and Transforming Data, Data Validation, and Handling Errors Useful Chapters in the Textbook Regarding this Lecture Chapter 26 Chapter 31 Chapter 32 Valuable Sources of Data http://aic.ucdavis.edu/research/datasources.htm http://www.ers.usda.gov/data-products.aspx http://www.bls.gov/ http://www.cdfa.ca.gov/statistics/ https://www.census.gov/ Importing Data The data that you work with in Excel can be entered in a few basic ways. You can enter the data by hand one data cell at a time which can be inefficient. Importing Data Cont. You can copy the data and try to paste it into Excel. Fortunately, Excel has the capability to import many different types of data. Importing Data Cont. There are several sources you can import data from: Access Database From the Web From Text From other Sources Copy and Paste Sometimes you can input data into Excel by just copying it and then pasting it. To do this, go to the source document, highlight the data, copy it, and then paste it into Excel. Sometimes Excel is smart enough to enter the data correctly. Copy and Paste Other times it will bring the data in as a text in a single column. Excel has the ability to turn data that is in a single column into data that spans multiple columns. In class we will work with: http://www.cdfa.ca.gov/Statistics/PD Fs/ResourceDirectory_2013.pdf Importing Data Through the Web On the Data Ribbon under Get External Data, there is a button that allows you to get data from the Web. When you press this button, Excel brings up a page that looks like a web page. From here you can enter the web page that has the data you are interested in importing. Importing Data Through the Web Cont. Once you are on the web page, you will see yellow arrows and associated box around what Excel can import. Click on the yellow arrow to select the data and then click on import. Importing Data Through the Web Cont. Try the import from web tool with the following websites: http://www.bls.gov/news.release/cpi.t01 .htm http://finance.yahoo.com/q/hp?s=YHOO Handling Duplicate Values and Creating Histograms There are times when your data set has many duplicate values and you are interested in the frequency of those values known as a histogram. Excel has the ability to remove duplicate values on the Data ribbon. Once you remove these duplicates, you can use the unique values to develop a histogram. Histogram In-Class Activity In column A, copy the RandBetween(1,10) function in cells A1:A5000. Copy and paste special those values into the C column. Remove the duplicates from this new column. Create a histogram out of the original data using the non-duplicate values and the Countif() function. Press F9 several times to see how the histogram changes. Data Validation Excel has a tool that can ensure that the data that is being entered is the correct type of data. This tool is the Data Validation Tool located on the Data ribbon. The tool has three tabs: Settings Input Message Error Alert Data Validation Cont. The Data Validation tool can check to see if the data entered is a: Whole number Decimal List Date Time Certain text length Custom (which is based on a formula) Data Validation Cont. With the Data Validation tool, you can set-up a message that tells the individual what type of data they should enter. The Data Validation tool allows you to also put an error message in case a correct value is not entered. Data Validation Cont. You have the option to: Stop the individual before the wrong data is entered, Provide a warning to the individual about the wrong data, or Provide information to the individual regarding the wrong data. Different Types of Errors #DIV/0!—This error alerts you when you have divided by zero. #N/A—This error alerts you when the information is unavailable. #NAME?—This error alerts you Excel does not know the name you are using, e.g., =SQRT(dog). Different Types of Errors Cont. #NULL!—This error indicates that the formula you are using does not have an intersection point. Most of the time this error occurs because you are missing an operator, e.g., =SUM(A3:A5 A4:B7) vs. =SUM(A3:A5 B3:B5). #NUM!—This error alerts you to an invalid number, e.g., Sqrt(-100). Different Types of Errors Cont. #REF!—This error alerts you to an invalid cell reference. This typically happens when you delete a referenced worksheet in a formula. #VALUE!—This error alerts you to incorrect data types, a function’s argument is a range when it should be a single value, e.g., =SQRT(A3:A4) Different Types of Errors Cont. The Iferror() function can handle errors when they come up. The Iserror() function can check to see if you have an error; it returns true or false. Auditing Toolbar and Formula Auditing Excel on its Formulas ribbon has a section for formula auditing. This tool allows you to trace the precedents and dependence of a cell. Auditing Toolbar and Formula Auditing Cont. It can allow you to toggle between the formulas and the results in a cell. It can show you how a formula is being evaluated. Circular Reference Errors When building formulas, you sometimes run into an error known as a circular reference. This error is alerting you to the fact that the cell you are currently calculating is somehow reliant upon itself causing a circular reference. Circular Reference Errors Cont. Sometimes you can use circular references as a tool for making a calculation, but typically it is an error you need to handle by fixing the circular reference.