I am editing this question and converted it to a query so I can customize the filters. I am having trouble getting the optional filter to work. Below is what it says when I try to filter but obviously when I don't filter, the query works. Please let me know how I can solve this!
Hi @awilliams8
You cannot have two where-clauses. There's three ways to do something like that:
- Simple, probably the one you need
where true
and role='agent'
[[and first_name={{firstname}}]]
- Using database function coalesce (should be available for most databases) - important to note the comma placements
where true
and role='agent'
and first_name=coalesce([[ {{firstname}} ,]] 'John', null)
- Complex defaults - important to use the comment syntax (
--
in this example) that works for your database, and the comment will only escape the same line.
[[where first_name={{firstname}} --]] where role='agent'
Thanks! Would I be able to use the same code for multiple filter options? If I would also want to be able to filter by brokerage name.
@awilliams8 Yes.