Expected behavior of filter on custom field of format list with multiple values
Added by Matej Polak 10 months ago
hi!
I am trying to understand the expected behavior for list custom fields with multiple values enabled.
Example:
Custom Field: Flags
Format: List
Multiple values: true
Possible values: a, b, c, d
Issue examples:
1. Flags set to a, b
2. Flags set to a, c
3. Flags set to b, c
4. Flags set to a
5. Flags set to b
Filter example @1:
on Flags, condition "is a, b".
Result of query:
Issues: 1, 2, 3, 4, 5
My Expected result:
Issues: 1
Instead of providing explicit result (AND), the result is all issues that have a OR b present in their list.
If this is the official expected result, is there a feature that can control the logical operator for the list of values?
How i can achieve the expected result?
Condition "is not" is also tricky :).
cheers
Replies (1)
RE: Expected behavior of filter on custom field of format list with multiple values - Added by Darrin Vitiello 5 months ago
Hi!
It looks like you're dealing with a custom field configured to accept multiple values, and you're seeing results that don't match your expectations due to how the query interprets the list values.
In your case, when you set the condition to "is a, b", the system appears to be treating the condition as an OR operation rather than an AND operation. This results in all issues that have either "a" or "b" (or both) appearing in the results, rather than only those that have both "a" and "b".
Expected Behavior
For your expected behavior, where you want issues to only be returned if they have all the specified values (e.g., "a" AND "b"), the system would need to support a logical AND operation for list fields, which it seems isn't the default behavior here.
Solutions and Workarounds
Check System Settings or Documentation:
Review the documentation for your system or tool to see if there's an option to configure the logical operator used in list field conditions. Some systems allow you to choose between AND/OR operations, but it might not always be available or might require specific configurations.
Custom Filtering:
If your system supports custom scripts or filters, you might be able to implement a custom query that enforces the AND logic you need. This often involves more advanced querying or scripting capabilities.
Manual Post-Filtering:
As a workaround, you could perform the initial query with the OR condition, and then manually filter the results to only include issues that meet the AND condition using additional tools or scripting.
Feature Request:
If the feature to control the logical operator is not available, consider submitting a feature request to the developers or support team of your tool. They may consider adding this functionality in future updates.
Example for Manual Post-Filtering:
If you retrieve issues with either "a" or "b", you can then process this result set programmatically (e.g., using a script) to filter out only those that include both "a" and "b". Here's a pseudo-code example:
Copy code
- Example in Python
issues = [1, 2, 3, 4, 5] # IDs from the query
flags = {
1: ['a', 'b'],
2: ['a', 'c'],
3: ['b', 'c'],
4: ['a'],
5: ['b']
}
- Desired values
required_flags = {'a', 'b'}
- Filter issues to match all required flags
result_issues = [issue for issue in issues if required_flags.issubset(set(flags[issue]))]
print(result_issues) # Should print [1]
Feel free to adjust according to your environment or system capabilities.
Cheers!