Filtering
Use the MQL WHERE
clause to filter which surveys are included in the results. The WHERE
clause is available to list, aggregation, and distribution queries.
Here are some examples.
Overall satisfaction less than 5
WHERE ov_satisfaction < 5
Responses on or after January 1st, 2009
WHERE responsedate >= '2009-01-01'
Responses in a time period
Using the timeperiod table, information about the available timeperiods can be accessed. Then, the ID of a timeperiod can be used to filter on surveys within this timeperiod:
WHERE timeperiod(625, responsedate)
This filters for all surveys with responsedate in the timeperiod with the ID 625 (which for the demo 'mainstreet' company happens to be "Calendar Year 2006").
Surveys containing the word "john." Performs Lucene text search.
WHERE TEXT 'john'
Surveys where unitid is one of 4, 12, or 187
WHERE unitid IN(4, 12, 187)
Overall satisfaction less than 5 and unitid is different from 4, 12, or 187
WHERE ov_satisfaction < 5 AND NOT unitid IN(4, 12, 187)
A specific business unit
WHERE unitid='Detroit'
A specified set of business units
WHERE unitid IN ('Chicago', 'Detroit')
A group of business units
WHERE group='California'
Note that any one business unit can be a member of multiple groups, e.g. both 'California' and 'USA', so the use of the equals operator can be confusing as the same survey may match both group='California' and group='USA'.
Several groups of business units
WHERE group IN ('California', 'Texas')
Time period
WHERE responsedate >= '2006-01-01' AND responsedate < '2007-01-01'
Time period more precisely, using a time stamp
WHERE responsedate.date_and_time >= '2006-01-01 12:00:00' AND responsedate.date_and_time < '2006-01-01 16:00:00'
MQL API does not support the use of timezone in the filter. Additionally, Medallia Experience Cloud uses Pacific time as the default timezone, so every date and time you see in Experience Cloud is based on Pacific time. To get the desired results using this filter, convert the date and time to a Pacific Time (America/Los_Angeles) time zone with DST, then pass that date and time stamp.
Customer segment
WHERE personal_age_alt0='Age 35-44'