Using formulae

HomeShow all | About | Differences from Excel | Examples | Operators | Functions

About

OxonStat formulae allow new Variables to be created using any combination of constants, variables, operators and functions. Operators allow things such as addition and subtraction. Functions provide common mathematical transformations such as logs and trigonometry, but also provide more advanced things like normally distributed random number sequences.

Differences from Excel

If you are familiar with formulae in Microsoft Excel or other spreadsheets you will find that formulae in OxonStat are slightly different, in a useful way. In a spreadsheet if you wanted to calculate the BMI for a series of people you would typically have to create a formula for the first row and then copy and paste it for all other rows. If you later added more rows to the spreadsheet you would have to copy the formula to those new rows in order for it to work.

Assuming your data for Weight are in column A and Heights in column B, you would have formulae such as "=A1/B1^2", "=A2/B2^2" etc, which makes it more difficult to find out what is happening when you revisit the spreadsheet some time later.

In OxonStat life is simpler. You create a Column named Weight and another named Height and enter some data.

You can then create a new column called BMI, and assign it a formula of "Weight / Height^2" and press OK.

The results are as follows:

Entering new values for Weight and Height automatically calculates the results for BMI, even if you add rows to the Dataset. Obviously, altering a Height or Weight causes the BMI to be recalculated accordingly.

There is also a dialog box where you can view all the formulae within a given Dataset.

Examples

Assuming you have Forumula Results in
A Variable called Height recorded in metres. A Variable called Weight recorded in kg. Weight / Height ^ 2 The Body Mass Index (BMI)
A Variable called Height recorded in centimetres. A Variable called Weight recorded in kg. Weight / ( Height / 100 ) ^ 2 The Body Mass Index (BMI)
A Variable called Angle recorded in degrees. sin( radians( Angle ) ) The sine of the angle

 

Writing Baseline Values and Variables

When typing elements into an OxonStat formula, use these simple formatting rules. Please note that case is not important for matches or variable tracking; the software treats uppercase and lowercase letters identically for your column names and logical comparisons (e.g., Age, age, and AGE are handled as the exact same variable).

However, OxonStat completely honours the exact case of any textual values you physically enter or save in your Datasets.


 

How OxonStat Solves Your Formulas

When you combine your variables with fixed values, OxonStat processes the calculations from left to right using a strict mathematical hierarchy.

  1. Parentheses () & Functions :
    Anything wrapped in brackets or written as a function (like LN() or sqrt()) is solved first. Use brackets to isolate a specific calculation you want performed before anything else.
     
  2. Exponents (^) :
    Power calculations (such as squaring a patient's height for a BMI calculation) are performed next.
     
  3. Multiplication & Division (* , /) :
    These are solved next, moving from left to right.
     
  4. Addition & Subtraction (+ , -) :
    These are solved next, moving from left to right. This includes adding or subtracting specific time intervals (e.g., EnrollmentDate + #6 weeks#).
     
  5. Comparisons (<, <=, >, >=, =, <>) :
    The system finishes all math before checking your grouping criteria. It then checks if values match, exceed, or fall below your thresholds (<> means "not equal to"). Case-insensitive matching applies here.
     
  6. Connecting Logic (and , or) :
    These logic gates hold completely equal priority and are evaluated strictly from left to right as they appear in your formula (ignoring whether they are typed as AND, Or, or and).
     

The Golden Rule for Clinical Logic: Use Brackets

Because and and or are treated equally and processed straight from left to right, changing the order of your words changes who gets included in your cohort. If you mix and and or in the same line, always use brackets to make your clinical intent explicit.


 

Functions

The available functions are documented in the Function reference