Crafting clear prompts is the key to getting accurate formulas from AI. This section provides templates, patterns, and techniques to help you describe your calculations precisely.
Every effective prompt contains four elements:
Element | Purpose | Example |
---|---|---|
Action | What to calculate or transform | “Calculate”, “Show”, “Combine”, “Count” |
Conditions | When logic applies (if needed) | “If Status is Active”, “When Date is past” |
Field references | Which data to use | “Use the Price and Quantity fields” |
Output format | How to display the result | “Round to 2 decimals”, “Show as percentage” |
Complete example: “Calculate the total cost by multiplying Quantity by Unit Price. If the customer has a Premium membership, apply a 15% discount. Round the result to 2 decimal places.”
Basic calculation: “[Operation] [Field1] and [Field2]” Example: “Multiply Hours Worked and Hourly Rate”
With rounding: “[Operation] [Field1] and [Field2], then round to [X] decimal places” Example: “Divide Total Cost by Number of Items, then round to 2 decimal places”
Multi-step calculation: “First [operation1], then [operation2], finally [operation3]” Example: “First multiply Price by Quantity, then subtract Discount Amount, finally add Tax”
Related: Number field for storing calculated results
Simple IF: “If [Field] is [condition], show [value], otherwise show [other value]” Example: “If Stock Level is below 10, show ‘Reorder’, otherwise show ‘In Stock’”
Multiple conditions (nested IF): “If [Field] is [condition1], show [value1]. If [condition2], show [value2]. Otherwise show [value3].” Example: “If Priority is High, show ‘Urgent’. If Priority is Medium, show ‘Normal’. Otherwise show ‘Low’.”
Combining conditions (AND/OR): “If [Field1] is [condition1] AND [Field2] is [condition2], show [value]” Example: “If Status is Active AND Payment Date is in the past, show ‘Paid’”
Learn more about Boolean field for true/false conditions
Date difference: “Calculate the number of [days/weeks/months/years] between [Date1] and [Date2]” Example: “Calculate the number of days between Order Date and Delivery Date”
Date comparison: “If [Date Field] is [before/after] [reference date], show [value]” Example: “If Due Date is before today, show ‘Overdue’, otherwise show ‘On Time’”
Add/subtract time: “Add [number] [days/weeks/months] to [Date Field]” Example: “Add 30 days to Start Date”
Working days calculation: “Calculate business days between [Date1] and [Date2], excluding weekends” Example: “Calculate business days between Project Start and Project End, excluding weekends”
Learn more about Date and time fields, Working with timezones
Concatenation: “Combine [Field1], [Field2], and [Field3] with [separator] between them” Example: “Combine First Name and Last Name with a space between them”
Conditional text: “Show [text] if [condition], otherwise show [other text]” Example: “Show ‘Complete’ if Progress is 100, otherwise show ‘In Progress’”
Text extraction: “Extract the first [X] characters from [Field]” Example: “Extract the first 3 characters from Product Code”
Case conversion: “Convert [Field] to [uppercase/lowercase/title case]” Example: “Convert Email Address to lowercase”
Learn more about Single line text field, Long text field
Simple percentage: “Calculate [Field1] as a percentage of [Field2]” Example: “Calculate Actual Sales as a percentage of Target Sales”
Percentage change: “Calculate the percentage change from [Old Value] to [New Value]” Example: “Calculate the percentage change from Last Month Revenue to This Month Revenue”
Apply percentage: “Multiply [Field] by [percentage]%” Example: “Multiply Base Salary by 115% for the adjusted amount”
Counting related records: “Count the number of [Related Table] linked to this record” Example: “Count the number of Tasks linked to this Project”
Sum from related records: “Sum the [Field] from all linked [Related Table] records” Example: “Sum the Amount from all linked Invoice Items”
Average from related records: “Calculate the average [Field] from linked [Related Table] records” Example: “Calculate the average Rating from linked Reviews”
Learn more about Link to table field, Lookup field, Count field, Rollup field
Always specify what should happen with unusual data:
For blank fields: “If [Field] is blank, show [default value]” Example: “Calculate Total Cost, but if Quantity is blank, use 1 as the default”
For zero values: “If [Field] is zero, show [message] instead of dividing” Example: “Divide Revenue by Units Sold, but if Units Sold is zero, show ‘N/A’”
For negative numbers: “If the result is negative, show 0 instead” Example: “Calculate Profit (Revenue minus Costs), but if negative, show 0”
Problem: “Use the date field”
Solution: “Use the field called ‘Due Date’”
Problem: “Calculate the total”
Solution: “Calculate the total by adding Invoice Amount and Tax Amount”
Problem: “Show the status”
Solution: “Show the value from the Status field, which contains ‘Active’, ‘Pending’, or ‘Closed’”
Decimal places: “Round to [X] decimal places” Example: “Show result rounded to 2 decimal places”
Currency: “Format as currency with [currency symbol]” Example: “Format as currency with $ symbol”
Percentage display: “Show as a percentage with [X] decimal places” Example: “Show as a percentage with 1 decimal place (e.g., 45.5%)”
Text case: “Display in [UPPERCASE/lowercase/Title Case]” Example: “Display result in UPPERCASE”
Learn more about Field configuration options for formatting after formulas are created
For complex formulas, break your request into logical steps:
Instead of: “Calculate the discounted price with tax and show if it’s over budget”
Try this: “Step 1: Multiply Price by Quantity to get Subtotal. Step 2: If Customer Type is ‘Wholesale’, apply 20% discount. Step 3: Add 10% tax to the result. Step 4: If the final amount is greater than Budget Amount, show ‘Over Budget’, otherwise show ‘Within Budget’.”
This approach helps AI understand:
❌ Avoid | ✅ Do Instead | Why |
---|---|---|
“Calculate discount” | “Multiply Price by 0.85 to apply 15% discount” | Be explicit about the math |
“Use the date” | “Use the Due Date field” | Specify exact field names |
“Show status” | “If Score > 80 show ‘Pass’, otherwise ‘Fail’” | Define logic clearly |
“Make it a percent” | “Divide Completed by Total and multiply by 100” | Explain the calculation |
“Add them together” | “Add Field1, Field2, and Field3” | Name all fields |
“Format nicely” | “Round to 2 decimals and show currency symbol” | Specify exact format |
If your first formula doesn’t work perfectly:
1. Start simple: “Multiply Price by Quantity”
2. Add complexity: “Multiply Price by Quantity, then round to 2 decimals”
3. Incorporate conditions: “Multiply Price by Quantity. If the result is over 1000, apply 10% discount. Round to 2 decimals.”
4. Handle edge cases: “Multiply Price by Quantity. If Quantity is blank, use 1. If the result is over 1000, apply 10% discount. Round to 2 decimals.”
Each iteration improves accuracy without overwhelming the AI with complexity upfront.
Order total with tax: “Multiply Quantity by Unit Price, then add Tax Amount calculated at 8%”
Shipping cost logic: “If Order Total is over $100, set shipping to $0. If over $50, set shipping to $5. Otherwise $10.”
Inventory status: “If Stock Quantity is less than Reorder Point, show ‘Order Stock’, otherwise show ‘Sufficient’”
Learn more about Single select field for status values
Project health: “If Progress is 100%, show ‘Complete’. If Due Date is past and Progress is less than 100%, show ‘Overdue’. If Progress is over 50%, show ‘On Track’. Otherwise show ‘At Risk’.”
Time tracking: “Calculate the number of business days between Start Date and End Date, excluding weekends”
Budget variance: “Calculate (Actual Cost minus Budgeted Cost) divided by Budgeted Cost, shown as a percentage”
Learn more about Calendar view, Timeline view
Employee tenure: “Calculate years and months between Hire Date and today”
Bonus calculation: “Multiply Base Salary by Performance Rating percentage. If Employment Type is ‘Full-Time’, add $1000. Round to nearest dollar.”
Leave balance: “Start with 20 days. Subtract Days Taken. If result is less than 5, show ‘Low Balance’, otherwise show the number.”
Learn more about Collaborator field for team member references
Payment status: “If Payment Date is filled and Amount Paid equals Invoice Total, show ‘Paid in Full’. If Payment Date is filled but Amount Paid is less, show ‘Partial Payment’. If Invoice Due Date is past, show ‘Overdue’. Otherwise show ‘Pending’.”
ROI calculation: “Calculate (Revenue minus Investment) divided by Investment, multiply by 100, show as percentage with 1 decimal”
Compound interest: “Calculate Principal multiplied by (1 + Rate)^Years, round to 2 decimals”
Lead scoring: “Start with 0. If Company Size is ‘Enterprise’, add 50 points. If Budget is over $10,000, add 30 points. If Timeline is ‘Immediate’, add 20 points. Show the total score.”
Deal probability: “If Stage is ‘Proposal Sent’, show 50%. If Stage is ‘Negotiation’, show 75%. If Stage is ‘Closed Won’, show 100%. Otherwise show 25%.”
Commission calculation: “Multiply Deal Value by Commission Rate. If Deal Value is over $50,000, add bonus of $500.”
Learn more about Kanban view for pipeline management
After generating a formula, validate it:
Test with typical data:
Test edge cases:
Test boundary conditions:
Visual verification:
If any test fails, refine your prompt and regenerate.
Still stuck? Try these resources:
Since AI doesn’t remember previous generations, maintain a prompt library:
Create a reference table:
Or use external notes:
This saves time when creating similar formulas across different tables or workspaces.
Learn more about how to create a table for organizing your prompt library
Need help? Visit the Baserow community or contact support for assistance with your account.