Why Use Conditional Fields?
Not every row in your spreadsheet has the same data. Some recipients are VIP members, some orders include a discount, and some certificates warrant an honor badge. Without conditional fields, you would need separate templates for each variation — or accept that every merged page shows the same layout regardless of the data.
Conditional fields solve this by letting you show or hide individual fields based on spreadsheet values. One template, one merge job, dynamic output per row.
Prerequisites
You need a PDF template and a spreadsheet loaded in the Mergram editor. If you’re new to the editor, start with the mail merge basics guide first.
Setting Up Your First Conditional Field
Step 1: Prepare your spreadsheet
Add columns that your conditions will reference. These can be data columns you already use, or dedicated flag columns.
Example spreadsheet for tiered certificates:
| Name | Course | Score | Tier |
|---|---|---|---|
| Alice Chen | Data Analytics | 95 | gold |
| Bob Martinez | Data Analytics | 72 | silver |
| Carol Johnson | Data Analytics | 88 | gold |
| David Kim | Data Analytics | 60 | standard |
| Eva Rossi | Data Analytics | 45 | standard |
Example spreadsheet for invoices:
| Customer | Amount | Discount | Status | TrackingNumber |
|---|---|---|---|---|
| Acme Corp | 500 | 50 | paid | |
| Beta LLC | 300 | pending | TRK-9982 | |
| Gamma Inc | 150 | 20 | paid | |
| Delta Co | 800 | shipped | TRK-4421 |
Flag columns
You don’t need to display every column as a field. A column can exist solely to drive conditions. For example, a Tier column can control which badge appears without the tier text itself showing on the PDF.
Step 2: Place your fields
Drag all the fields you need onto the canvas — both the fields that always appear and the ones that will be conditional.
For the certificate example, place:
- Name — always visible (no conditions)
- Course — always visible (no conditions)
- Score — always visible (no conditions)
- “Gold Member” badge — conditional (image or text field)
- “With Honors” label — conditional (text field)
Overlapping conditional fields
You can place multiple conditional fields in the same position. Only the fields whose conditions are met will render. This is useful for tiered badges where only one should appear per row.
Step 3: Add conditions
- Click a field on the canvas to select it
- Click the Conditions button (filter icon) in the field properties toolbar
- Click Add Condition
- Choose a column (e.g.,
Tier), an operator (e.g.,Equals), and a value (e.g.,gold) - Choose the mode:
- Show when met — field only appears when the condition is true
- Hide when met — field is hidden when the condition is true
For the gold badge: set the Tier column equals gold with Show when met mode.
Step 4: Preview across rows
Use the Preview button and navigate through rows to verify:
- Alice (gold) — badge appears
- Bob (silver) — no badge
- David (standard) — no badge
Practical Examples
Tiered Certificate Badges
Use a single Tier column to control which badge appears:
| Field | Condition | Mode |
|---|---|---|
| Gold badge image | Tier equals gold | Show when met |
| Silver badge image | Tier equals silver | Show when met |
| Standard badge image | Tier equals standard | Show when met |
Place all three badge images in the same canvas position. Only the matching tier’s badge renders for each recipient.
Alternative approach
If your tiers follow a score threshold (e.g., gold = 90+), you can use the Greater or equal operator on the Score column instead. Set the gold badge to show when Score greater or equal 90. This eliminates the need for a separate Tier column.
Optional Product Photos
When only some rows have product images, hide the image field for rows without a filename:
| Field | Condition | Mode |
|---|---|---|
| Product photo (image) | Photo Is not empty | Show when met |
In your spreadsheet, leave the Photo column blank for products without images:
| Product | Price | Photo |
|---|---|---|
| Widget A | $12.99 | widget-a.jpg |
| Widget B | $8.50 | |
| Widget C | $15.00 | widget-c.jpg |
Only Widget A and Widget C will show a product photo in the merged output.
Discount Display on Invoices
Show a discount amount only when a discount exists, and show a “PAID” stamp only for paid invoices:
| Field | Condition | Mode |
|---|---|---|
| Discount amount text | Discount Is not empty | Show when met |
| ”PAID” stamp (text or image) | Status equals paid | Show when met |
| ”PENDING” label | Status equals pending | Show when met |
This creates a single invoice template that adapts to each customer’s situation.
Regional Address Formats
Show or hide address components based on country:
| Field | Condition | Mode |
|---|---|---|
| Province/State line | Country equals US | Show when met |
| Postal code line | Country does not equal US | Hide when met |
Case insensitivity
All text comparisons are case-insensitive. A condition for US will match us, Us, and US. You don’t need to worry about inconsistent capitalization in your spreadsheet.
Tracking Barcodes for Shipped Orders
Only render a tracking barcode when a tracking number exists:
| Field | Condition | Mode |
|---|---|---|
| Tracking barcode (barcode) | TrackingNumber Is not empty | Show when met |
Rows without tracking numbers skip the barcode entirely — no broken barcode image on the output.
Multi-Condition Warning Labels
Use AND logic to show a warning only when multiple criteria are met:
| Field | Condition 1 | Condition 2 | Mode |
|---|---|---|---|
| ”Low Stock” warning | Quantity less than 10 | ReorderStatus does not equal ordered | Show when met (AND) |
The warning only appears when stock is low and no reorder has been placed.
Choosing the Right Operator
Text operators
Use these for columns with text values like names, statuses, categories, and codes:
| Operator | Best for | Example |
|---|---|---|
| Equals | Exact category matching | Tier equals gold |
| Does not equal | Exclusion | Status does not equal cancelled |
| Contains | Partial text matching | Email contains @company.com |
| Starts with | Prefix matching | Phone starts with +1 |
| Ends with | Suffix matching | Email ends with .edu |
| Is not empty | Optional fields | Photo is not empty |
| Is empty | Missing data | Notes is empty |
Numeric operators
Use these for columns with numbers like prices, quantities, and scores:
| Operator | Best for | Example |
|---|---|---|
| Greater than | Thresholds | Price greater than 100 |
| Less than | Limits | Quantity less than 5 |
| Greater or equal | Minimum thresholds | Score greater or equal to 80 |
| Less or equal | Maximum thresholds | Discount less or equal to 50 |
Empty cells and numeric operators
Empty cells are treated as 0 in numeric comparisons. If you need to distinguish between “no value” and “zero”, use the Is empty or Is not empty operator first, or add a separate condition with AND logic.
Show vs. Hide Mode
Choosing between Show when met and Hide when met changes the logic direction:
- Show when met — The field is invisible by default and only appears when conditions match. Use this for bonus content (badges, discounts, optional images).
- Hide when met — The field is visible by default and disappears when conditions match. Use this for removing content (hiding a “Renew” button for active subscribers).
Which mode to choose?
Ask yourself: “Should this field appear for most rows or few rows?” If it should appear rarely, use Show when met. If it should appear for most rows and only be hidden in specific cases, use Hide when met.
Combining Multiple Conditions
When you add multiple rules to a single field, choose how they combine:
AND logic (All conditions)
Every rule must be true. Use when all criteria must be satisfied simultaneously.
Example: Show a “Priority Support” badge only when Tier equals gold and SupportPlan equals premium.
OR logic (Any condition)
At least one rule must be true. Use when any one of several conditions is sufficient.
Example: Show an “Action Required” label when Status equals expired or Status equals cancelled.
Complex logic
If you need logic like “(A AND B) OR C”, create a formula column in your spreadsheet that computes the result. For example, in Excel: =IF(AND(A2="gold", B2="premium"), "yes", IF(C2="urgent", "yes", "no")). Then base your condition on that single column.
Best Practices
-
Use
Is not emptyfor optional image fields — Images that lack a matching filename produce a warning and are skipped. Setting the condition toIs not emptyon the image column prevents the warning and makes the intent clear. -
Place tiered fields in the same position — Multiple conditional fields (e.g., gold/silver/bronze badges) can overlap. Only the active one renders. This keeps your layout clean.
-
Preview at least 5 rows — Cycle through your data to spot edge cases: blank cells, unexpected values, and text that overflows when a nearby conditional field is hidden.
-
Test with boundary values — For numeric conditions, test with values at the boundary (e.g., exactly 80 for “greater or equal to 80”) and on both sides.
-
Use flag columns for complex decisions — When your condition logic gets complicated, compute it in the spreadsheet and use a simple flag column (e.g.,
ShowBadgewithyes/no) to drive the condition. -
Keep conditions per-field — Each field has its own independent conditions. You cannot group conditions across fields, so plan which fields share the same column reference.
Troubleshooting
Condition not triggering: Verify that the column name in the condition matches your spreadsheet header. Check for trailing spaces in your spreadsheet cells — use TRIM() to clean them.
Field appears when it shouldn’t (or vice versa): Double-check whether you selected Show when met or Hide when met mode. The two modes produce opposite behavior.
Numeric condition not working with text: Make sure the column contains numeric values, not text like “$50” or “50 units”. The comparison uses the raw cell value. Pre-clean your data or use a separate numeric-only column.
All fields with conditions appear/disappear: You may have set conditions on the wrong column. Click each field and verify the selected column in the Conditions panel.
Get Started
Open the Mergram editor, upload your PDF template and spreadsheet, place your fields, and start adding conditions. For a full technical reference of all operators and settings, see the Conditional Fields documentation.