Filtering Message Template Variables
Overview
When designing Message Templates in Welkin, you can define filter variables that dynamically display and manipulate data from Custom Data Types (CDTs). Filter variables work similarly to pivot tables or database queries, allowing you to extract specific subsets of data based on field values and display them in messages and assessment PDFs.
This functionality enables sophisticated communication that references only the most relevant data points, such as displaying medication names and dosages for a specific medication category, or showing only recent assessment responses that meet certain criteria.
Key Concepts
Filter Variable – A dynamic reference that extracts and displays specific data based on conditions
Pivot Table Analogy – Similar to filtering rows/columns in a spreadsheet based on criteria
Custom Data Type (CDT) – The data source for the filter (must contain multiple fields)
Filter Field – The field used to determine which records to display
Display Field – The field whose values are actually shown in the message
Prerequisites
You have created a Message Template in Designer
You have CDTs with multiple related fields (e.g., medication names and dosages)
You understand basic Welkin CDT structure
Your Message Template is being used for patient communications
Creating Filtered Variables
Step 1: Access Message Template Configuration
Log into Designer
Click Create Draft
Navigate to Message Template in the left sidebar
Either:
Click + New to create a new message template, OR
Click on an existing template to edit it
Step 2: Open the Variable Selector
In the Message Template editor, locate the Variable button (usually above the message body)
Click Variable or the {} icon to open the variables drawer
The right sidebar displays available variables organized by type:
System Variables
Patient Variables
Custom Data Type Variables
Custom Data Type Filter Variables (what we're configuring)
Step 3: Configure Filter Variables
In the variables drawer, locate the "Custom Data Type Variable" section (may be labeled as "Filtered Variables" or similar).
Setting Up a Filter
Select the Source CDT – Choose the Custom Data Type that contains the data you want to filter
Select the Filter Field – Choose which field will be used as the filtering criteria
Specify the Filter Value – Define what value(s) the filter field should match
Select the Display Field – Choose which field's values will actually be shown in the message
Step 4: Copy the Generated Variable
Once configured:
The system generates a variable reference (often shown with special syntax like
{{cdt_name[filter_field=value].display_field}})Click to copy this variable
Paste it into your message body where you want the filtered data to appear
Practical Examples
Example 1: Display Specific Medication Information
Scenario: Patient is on multiple medications; you want to show only blood pressure medication names and dosages in a message.
Setup:
Source CDT:
medicationsFilter Field:
medication_categoryFilter Value:
"blood pressure"Display Field:
medication_nameanddosage
Generated Variable: {{medications[medication_category="blood pressure"].medication_name_dosage}}
Message Result:
Example 2: Show Recent Assessment Responses
Scenario: Show only the most recent depression screening responses in a follow-up message.
Setup:
Source CDT:
depression_assessment_responsesFilter Field:
assessment_dateFilter Value:
last 7 daysor specific dateDisplay Field:
questionandpatient_response
Generated Variable: {{depression_responses[recent=true].response_text}}
Message Result:
Example 3: Filter by Clinical Category
Scenario: Show only critical vital signs that are out of normal range.
Setup:
Source CDT:
vital_signsFilter Field:
is_abnormalFilter Value:
trueDisplay Field:
vital_nameandvalue
Generated Variable: {{vital_signs[is_abnormal=true].display_name}}
Message Result:
Using Filtered Variables in Messages
In Patient Messages
Compose your message text
Reference the filtered variable where you want data to appear
Use formatting like lists or tables to organize multiple filtered results
Example:
In Assessment PDFs
Filtered variables can also be used in PDF templates (Word documents):
Create your PDF template in Word
Include filtered variable syntax using the same format
When PDF generates, variables are replaced with filtered data
Example in PDF:
Advanced Filtering Techniques
Multiple Filter Conditions
Some systems support combining multiple filter criteria:
This would show data where BOTH conditions are true.
Complex Filter Logic
Depending on your Welkin version:
OR Logic: Show data matching ANY condition
NOT Logic: Show data that does NOT match a condition
Range Filtering: Filter by numeric ranges (e.g., "score > 10")
Date Ranges: Filter by date ranges (e.g., "past 30 days")
Nested Display Fields
You can sometimes display multiple fields together:
This would show all three fields concatenated.
Best Practices
Test Thoroughly – Send test messages with filter variables to ensure correct data displays
Use Clear Naming – Name CDT fields clearly so filter intent is obvious
Document Filters – Add comments explaining what each filter does for team knowledge
Avoid Over-Filtering – Keep filters simple; complex logic may be prone to errors
Regular Updates – Review messages if CDT structure changes
Consider Empty Results – What happens if no data matches the filter? Add fallback text:
Performance – Very large CDT data sets with complex filters may slow message rendering
Troubleshooting
Variable Not Populating
Problem: Message shows the variable syntax instead of data
Solutions:
Verify the filter field name matches exactly (case-sensitive)
Confirm the filter value matches actual data in the CDT
Check that the display field exists in the CDT
Verify the CDT has data entries for that patient
Incorrect Data Displaying
Problem: Filter shows wrong data or too much data
Solutions:
Review the filter criteria – may need to be more specific
Check CDT field values to ensure they match filter conditions
Verify display field is the correct one
Test with a different patient to isolate data issues
Empty Results
Problem: No data displays even though data exists
Solutions:
Check patient enrollment – may not have assessments in that CDT yet
Verify filter field values match exactly (including capitalization)
Confirm CDT is published and associated with the message
Check date filters if using time-based filtering
Related Topics
Filtering With Message Template Variables – Detailed variable reference
Custom Data Types (CDT): Designer – Creating CDTs for filtering
Create PDFs from Forms & Assessments – Using variables in PDFs
Automations that Trigger Outbound Communications – Using messages in automations
How to Create an Assessment or Form Template – Assessment data sources
Last updated
Was this helpful?