Creating A Series Of Workdays4

To create a series of dates in a range, with just weekdays (Monday through Fridays), you first enter your starting date in a cell (B2, in the example below), and then enter the following formula in the cell below that cell.


Then use the Fill Down utility to fill out your entire series of dates.

The formula to display the day of the week we have already met…


Read More

Text Formulas: Extracting First & Last Names

By combining the different text functions available in OOo Calc, some common name transformations can be performed.

Here are a few examples…

Using “Harry Potter in F1…

=LEFT(F1;FIND(” “;F1)-1) returns “Harry”

Note that without the -1 in the above formula, we would get a trailing space – making life difficult for us later on.

=RIGHT(F1;LEN(F1)-FIND(“*”;SUBSTITUTE(F1;” “;”*”; LEN(F1)-LEN(SUBSTITUTE(F1;” “;””))))) returns “Potter”

I think we need to explain the above formula a little bit. First off, when trying to develop formulas of this complexity – do not attempt to write it all at once.

This is what is known as a megaformula – a miniature program – squeezed into a single formula.

When extracting the last name like this – we use the RIGHT function – but it is not much use unless we know where the last name starts. It starts immediately after the last space character. We can find that with the FIND function. Howver FIND works from the left. If we could figure out how many space characters there are – we would be set. We do that by removing the space characters and seeing how much shorter the name is.

The whole procedure is illustrated below..

As an alternative to developing these megaformulas, you could also code this in Open Basic – but for that, we will wait another day.

Read More

Importing Tabular Data : CSV Files

If the various OOo Calc forums are an indicator of what gives Calc users the most grief, then importing data into Calc via CSV (coma separated values) files is up there with charting as one of the most error prone tasks.

Before you can perform data analysis with OOo Calc, you first need to import the data into the program. Supposedly, one of the more straightforward mechanisms for doing so is via CSV files. These are text files whose files have defined separators tab, comma, semicolon etc) that allow easy mapping from the CSV file into the cells of the spreadsheet.

In this tutorial, we will import some French population data into OOo Calc. The popdata.csv file is listed below.

From the File-Open dialog, we select File type TEXT CSV (*.csv *.txt) We then select the text CSV file we wish to import.

The Text Import dialog opens – which will give you a preview of your imported data. The default separator is comma, and fixed field width is unselected, so we do not need to change any of the settings in this window. Click OK

Now you can inspect the imported text data, making any formatting modifications that you deem necessary. Note that the width of the columns have been optimally sized by OOo Calc.

When it comes time to save your data and/or exit the OOo Calc application, you will be given the option of saving as a CSV file. If you do opt to save as a text CSV file, you will lose any formatting modifications that you made to the imported data.

Read More

Counting unique entries in a range

A good source of hints and tips for OOo Calc can be the numerous Excel blogs. One of the best is from Dick Kusleika.

This formula for counting the number of unique items in a range of cells was one of three suggested by Dick – but the only one that ported successfully to OOo Calc.

It is an array formula. Use Ctrl-Shift-Enter when entering it.

=SUM(IF(FREQUENCY(IF(LEN(A1:A10)>0;MATCH(A1:A10;A1:A10;0);””); IF(LEN(A1:A10)>0;MATCH(A1:A10;A1:A10;0);””))>0;1))

where A1:A10 is the range being analyzed..

Read More

Array Formulas: Working with Matrices

An array is a linked range of cells on a spreadsheet containing values. A formula in which the individual values in a cell range are evaluated is referred to as an array formula.

Not only can an array formula process several values, but it can also return several values. The results of an array formula is also an array.

The OOoCalc functions that are introduced here are TRANSPOSE, MMULT, and MINVERSE.

As an introduction to array formulas – we introduce one of the builtin array functions – TRANSPOSE, which as the same suggests – transposes the rows and columns of the original array to the target array.

In the example below, we wish to transpose A1:D3 to B6:D9.

With B6 selected – enter =TRANSPOSE(A1:D3) – followed by Ctrl-Shift-Enter. OOo Calc takes care of the rest! Note that in the Input Window – the function is embedded within { } indicating an array function. These are automatically added by OOo Calc.

OOo Calc also has a builtin function for multiplying matrices – MMULT. The use of this function is demonstrated in the example below.

We use Insert->Names->Define to define the two product matrices as Matrix1 and Matrix2. Using defined names to define and manipulate matrices is good practice – as is highlighting the matrices with different background colors.

To calculate the inverse of a matrix, we use the MINVERSE function. This is illustrated below.

We can now apply our knowledge of matrix manipulation in OOo Calc to solve for a system of linear equations. The technique is illustrated in the example below.

Read More

Webquery: Scraping stock quotes from MSN

In a previous entry we imported data from an HTML file on the local disk. In this example, we will extract stock quotes from an MSN site and import the data into OOo Calc spreadsheet.

We will import the stock quote information from this MSN webpage. A screen shot is shown below.

For this example, we import the data into the spreadsheet as before with Insert – External Data . The URL is;=INTC and the table we need to select is HTML_15.

You also need to make sure your proxy server settings are correct under Tools – Options (Internet)

Now, we can choose to have OOo Calc import this data at predefined regular intervals. This is useful – given the constantly changing nature of the stock prices. Also, each time that the user opens the document, OOo Calc will prompt to update the external links. Basically, what we have created is a ‘window’ to an external document. It can be a snapshot – or it can regularly monitor the target – updating accordingly.

Having extracted the data from the external website in it’s’raw’ form, we can use VLOOKUP to grab any piece of data we want. This is shown below.

Read More

Conditional Formatting II

To illustrate the application of conditional formatting, we consider the need to highlight dates in a spreadsheet that are fast approaching or are already past.

The original spreadsheet without highlighting.

Before we apply conditional, we define any custom cell formats we may need. In this case, we have cells highlighted orange and cells highlighted yellow. We open the conditional formatting dialog and evaluate two conditions. The order is important here. In the conditional formatting dialog, once a cell evaluates TRUE, it will not be evaluated again. With that in mind, we first evaluate if a date is past due. We then evaluate if a date is fast approaching.

The modified spreadsheet with conditional formatting applied. Using this technique, the spreadsheet has become more readable and any key dates or deadlines can be more readily identified.

Read More

Conditional Formatting: Comparing two Lists

We will use conditional formatting to identify unique entries between two lists.

In the sheet below, we have two lists of US States. We would like to identify the list entries that are unique to each list. This technique can also be applied to two versions of the same list to identify additions/removals.

Step 1: Select B2:B19 and open the Conditional Formatting dialog – below. We have already defined a formatting style that has a darker background.

In the Conditional Formatting dialog, select the “Formula is”option from the drop down list on the left and enter the formula as displayed below. Choose the predefined style. Exit the dialog.

We apply similar conditonal formatting to the D2:D19 array. I will leave that as an exercise for the reader.

The result after the conditional formatting is applied. Those cells that are shaded dark do not have a matching entry in the other list.

Read More

Regression Analysis II : Basic functions, charting

In a continuation from the previous tip, we look at some basic built-in functions for determining trendline coefficients of a X-Y plot.

For a series of X-Y values that we suspect have a linear relationship, we can determine the slope and y-intercept values of the linear approximation using the builtin functions SLOPE() and INTERCEPT as showb below. Compare these values to those we obtained when performig our regression analysis without using the builtin functions.

Now, plotting X-Y data is straightforward. Adding a trendline takes a little more work. We start off with the basic X-Y plot.

First, select the chart for editing by right-clicking anywhere inside the chart boundary. Now, before we add the trendline, we need to select the data series for editing. Move the cursor over one of the data points – you will see popup info about the nearest data point.

Left-click and the data series is now selected (below)

The Data Series dialog opens up. Select the Statistics tab (below). Select the Linear Regression curve and click OK

The modified X-Y plot with the newly added trend line.

Read More

Freezing row & column headers

For large spreadsheets that do not fit completely in the window, it is useful to be able to freeze the row and/or column headers to better view the data.

Consider the example below, where we have 12 columns and a large number of rows. By selecting the cell below and to the right of A1 and selecting Window – Freeze , you will now be able to scroll down or to the right while keeping the top row and left column frozen in place.

Note that once you close a sheet, the above setting disappears and you will need to refreeze your window when you reopen the sheet.

Read More