Spreadsheet functions in Base tables?

Creating tables and queries
Post Reply
olsza7
Posts: 2
Joined: Sun Aug 16, 2009 2:29 am

Spreadsheet functions in Base tables?

Post by olsza7 »

As part of my sales database, I am building a table of product sales with the following fields:

Product name / Price per unit / No. of units purchased / Total

I would like the "Total" field to be populated automatically as a product of "Price per unit" and "No. of units purchased", (e.g. if Price per unit = $5.00 and No. of units purchased = 2, Total will be automatically filled in as $10.00) - so that I don't have to type the Total in by hand for each record. Is it possible in Base?

I know that this can be easily done in Calc and I even created a spreasheet with the product function in Calc but when I tried importing it into Base, the spreadsheet function did not import.

Thank you!
QuazzieEvil
Volunteer
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: Spreadsheet functions in Base tables?

Post by QuazzieEvil »

You cannot make a table do calculations. You can either use code to perform the calculation during input, or create a view/query that has a calculated field.

view/query approach is the simplest to create. However, you must base any reports on the view rather than the original table, such that your calculations are performed.

To create a calculated field, enter the calculation (e.g. "Price" * "Count") in the Field row of a query/view, and give it a name in the alias row.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Spreadsheet functions in Base tables?

Post by Villeroy »

Store your data in some database.
Do all the list keeping, sorting, filtering and most of the simple calculations in the database.
Most tasks you can't do easily by means of SQL are easy to do in spreadsheets. This includes "positional tasks" (previous/next row) and mathematic tasks.

You can use all database tables and queries in Calc just like spreadsheet data. The only difference is:
1. The data are consistent and complete. No duplicates, text is text, numbers are numbers, dates are dates, mandatory values do not miss.
2. The imported tables have a clearly defined start and end. An imported db-range resizes with every refresh and has a precise amount of rows and columns below one row of column labels.
3. You can perform all kinds of calculations based on imported data and the formula ranges grow and shrink automatically with the imported data range. All formulas adjacent to the right side of an imported db-range will be inserted and deleted with every refresh of the growing and shrinking db-range.
4. You can work with virtual tables (constant filters and sort orders without user interaction). They can be multi-dimensional covering more than one 2-dimensional tables.
5. Calc can create data pilots directly from database tables.
6. There is no reason why one should not attach the database input form to a spreadsheet.
7 ... [to be continued]

[Tutorial] Using registered datasources in Calc
[Solved] Using Filter in Calc V3.1 with dates
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
olsza7
Posts: 2
Joined: Sun Aug 16, 2009 2:29 am

Re: Spreadsheet functions in Base tables?

Post by olsza7 »

Thank you both very much! I'll explore both approaches sometime this week.
OpenOffice 3.1.0
Windows Vista
Post Reply