Write effective AI prompts

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.

Anatomy of a great prompt

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.”

Prompt templates by calculation type

Mathematical operations

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

Conditional logic (IF statements)

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 and time calculations

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

Text manipulation

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

Percentage calculations

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”

Lookups and aggregations

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

Advanced prompting techniques

Handling edge cases

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”

Being specific about field names

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’”

Specifying output format

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

Multi-step prompt strategy

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:

  • The order of operations
  • When to apply conditions
  • How to structure nested logic

Common prompt mistakes to avoid

❌ 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

Iterative refinement process

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.

Prompt examples by industry

E-commerce

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 management

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

HR and recruitment

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

Finance

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”

Sales and CRM

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

Testing your prompts

After generating a formula, validate it:

Test with typical data:

  • ✅ Does it work for normal rows?
  • ✅ Are calculations accurate?

Test edge cases:

  • ✅ What happens with blank fields?
  • ✅ What if numbers are zero or negative?
  • ✅ How does it handle very large values?

Test boundary conditions:

  • ✅ Does conditional logic trigger at correct thresholds?
  • ✅ Are date comparisons accurate?

Visual verification:

  • ✅ Is output formatted as expected?
  • ✅ Do results make logical sense?

If any test fails, refine your prompt and regenerate.

Getting help with prompts

Still stuck? Try these resources:

  1. Use formula documentation: Review Formula field reference to understand available functions
  2. Check similar formulas: Look at Formula field overview for common patterns
  3. Ask the community: Post your requirement on the Baserow community forum
  4. Provide more context: Include example input and desired output in your prompt
  5. Try a different model: Switch from GPT-3.5 to GPT-4 for complex logic

Saving your successful prompts

Since AI doesn’t remember previous generations, maintain a prompt library:

Create a reference table:

  • Formula Type column (e.g., “Date Calculation”)
  • Prompt Text column (your successful prompt)
  • Notes column (when to use it)

Or use external notes:

  • Keep a document with prompt templates
  • Organize by category (math, dates, text, conditional)
  • Update when you discover better phrasing

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.