# UI for relative date filters

**URL:** <https://forum.mautic.org/t/ui-for-relative-date-filters/31568>\
**Category:** Ideas and Feature Requests\
**Tags:** user-interface\
**Created:** [April 5, 2024, 9:55am UTC](https://forum.mautic.org/t/ui-for-relative-date-filters/31568 "2024-04-05T09:55:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mika](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mika/32/12678_2.png) [@mika](https://forum.mautic.org/u/mika)\
**Post date:** [April 5, 2024, 9:55am UTC](https://forum.mautic.org/t/ui-for-relative-date-filters/31568/1 "2024-04-05T09:55:07Z")

</div>

**My idea is:**  
Include relative date filters in the UI.

**I think these groups of people would benefit from this idea:**  
Mainly new users who haven’t read the documentation yet.

**Why I think they would benefit from this idea:**  
Relative dates are very useful for email marketing. I think it should be obvious how to set them without looking into the docs.

**Are you willing to work on this idea?:**  
I can’t code, but I would like to test the UI.

---

<div class="post-metadata">

**Author:** ![andersoneccel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/andersoneccel/32/11792_2.png) [@andersoneccel](https://forum.mautic.org/u/andersoneccel)\
**Post date:** [April 16, 2024, 2:49pm UTC](https://forum.mautic.org/t/ui-for-relative-date-filters/31568/2 "2024-04-16T14:49:36Z")

</div>

Where would you use this feature?  
Make a step by step until we could reach where you would set up this

---

<div class="post-metadata">

**Author:** ![rrpp.online](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@rrpp.online](https://forum.mautic.org/u/rrpp.online)\
**Post date:** [April 16, 2024, 8:32pm UTC](https://forum.mautic.org/t/ui-for-relative-date-filters/31568/3 "2024-04-16T20:32:35Z")

</div>

We have simply used JavaScript to create filters that complement the default filtering area in Mautic. We just paste the JS code into ublic\_html/app/bundles/LeadBundle/Resources/views/Lead/\_filter.html.twig

![filter](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/7/74d60b0211fde8a571fcf2f6fa773f02e4597743.jpeg)

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [April 23, 2024, 12:16pm UTC](https://forum.mautic.org/t/ui-for-relative-date-filters/31568/4 "2024-04-23T12:16:53Z")

</div>

I think, but I’m not sure, that this might be similar to what I’m trying to do in a conversation we had [on Slack](https://mautic.slack.com/archives/CQMKV0RU1/p1713798730178789) this week (if not I can break this out into another post!):

> Has anyone else come across a need to have a filter on a segment which is something like 'downloaded xyz asset (which we currently have) in the past xyz time period (which we don’t yet have)?
> 
> Context being, we send an alert when folks download a specific resource to people who need to know - and people can download it more than once so we should be alerted each time it happens. So to do that with a campaign workflow (we can’t do it with a form based as it’s an asset which can be downloaded via link from anywhere) we need to use a segment. Segmenting based on the asset download means anyone who downloads it is in the segment, even if we remove them after the alert is sent they are added immediately the segment rebuilds again. I’ve cludged a workaround using ‘last active’ date being today, which isn’t 100% accurate but wondered if anyone else has come across this.

Ideally the segment filter would allow us to say, for example, downloaded xyz asset in the last 6 hours (or 1 day, or 12 months etc)

@a.towne also mentioned the following use cases:

> A few related filters that would be very useful:
> 
> - Was sent a specific email in a time frame
> - Read a specific email in a time frame
> - Visited a specific landing page in a time frame
> - Submitted a form (any)
> - Submitted a form in a time frame
> - Submitted a specific form
> - Submitted a specific form in a time frame
> - Was sent a specific SMS
> - Was sent a specific SMS in a time frame
> - Was sent a specific push notification
> - Was sent a specific push notification in a time frame
> - Custom object association (e.g. contact was linked to a particular custom object/item in a time frame, bought a specific product in a time frame, etc.)

We can already use the [relative date functions](https://docs.mautic.org/en/5.x/segments/manage_segments.html#date-options) but not in conjunction with something else when filtering in a segment (e.g. downloaded an asset in a specified time period relative to now).

Some input from @kuzmany:

> Even if we created downloaded at a specific time filter, it will not work because queries for each filter are built in separate queries. It’s complicated to explain but If you use asset download + download date \> certain date in the filter it will not work properly.  
> M5 added support for merged filters, and Custom Objects added support for it [Fix segment build when multiple custom items are linked to a contact by ts-navghane · Pull Request #333 · acquia/mc-cs-plugin-custom-objects · GitHub](https://github.com/acquia/mc-cs-plugin-custom-objects/pull/333)  
> This allows build chained queries, what could achieve that, but it’s not implement yet and it’s tricky due BC:

> Years ago I built it in another way [Segments stats improvements by kuzmany · Pull Request #7285 · mautic/mautic · GitHub](https://github.com/mautic/mautic/pull/7285)  
> It was merged into the public repo, but reverted because it had some issues.  
> It’s a bit painful because you are not able to create a segment filter at the moment like - give me all who read certain emails before some date. After integrated merging filters, it should work then  
> Probably bringing merged filters support by default in M6 with optional parameters to legacy version of filters would work.

---

<div class="post-metadata">

**Author:** ![a.towne](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/a.towne/32/1351_2.png) [@a.towne](https://forum.mautic.org/u/a.towne)\
**Post date:** [April 23, 2024, 2:21pm UTC](https://forum.mautic.org/t/ui-for-relative-date-filters/31568/5 "2024-04-23T14:21:26Z")

</div>

@mika Acquia is currently working on building an improved UI for relative date filters. That work will not include the other filters for activities that Ruth pasted from the Slack thread.

@escopecz if there’s anything else we have available at this point for what we’re working on, please share!

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [April 23, 2024, 2:26pm UTC](https://forum.mautic.org/t/ui-for-relative-date-filters/31568/6 "2024-04-23T14:26:26Z")

</div>

That’s right, Andy! Here is our work in progress UI for it:

 ![Screenshot 2024-04-23 at 16.25.14](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/c/cd7509a17f6a6b742d54f2987ec060dd73041e87.png)  
Will that solve this issue?

---

<div class="post-metadata">

**Author:** ![mika](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mika/32/12678_2.png) [@mika](https://forum.mautic.org/u/mika)\
**Post date:** [April 24, 2024, 5:10am UTC](https://forum.mautic.org/t/ui-for-relative-date-filters/31568/7 "2024-04-24T05:10:56Z")

</div>

That looks like what I had in mind. Great!  
The other mentioned related filters also look interesting.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)\
**Post date:** [April 25, 2024, 5:11pm UTC](https://forum.mautic.org/t/ui-for-relative-date-filters/31568/8 "2024-04-25T17:11:03Z")

</div>

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.
