New option for aggregate list: Minimum/Maximum for DateTime attributes - Mendix Forum

New option for aggregate list: Minimum/Maximum for DateTime attributes

29

The aggregate list option is currently geared towards numbers only. I would like to have the option to find a minimum and/or maximum value for a datetime attribute within a list.

The use case is to allow the user the option to set a datefrom/dateto range in a temp entity and use that to filter a list. For a database retrieve I could just use the range parameters in an XPath query, but if the objects are non-persistent it is not easy to filter based on a date range. In my specific case I want to call an API which has datefrom/dateto parameters.

Currently I have to add a loop through the entire list to find the minimum/maximum values before I can use them

asked
4 answers

Duplicate was submitted, https://forum.mendix.com/link/ideas/610

And received a comment, planned.

Created

Would love to see this implemented, depending on the usage, a retrieve with a minimum would be optimized to one single database query, where I now have to retrieve a list of objects and do a operation on that list.

We have it for the other datatypes, it seems odd that the datetime variant is missing.

Created

Hi Mike,

thanks for the helpful suggestion, you understood the idea perfectly well! 

Unfortunately a database retrieve is not possible because the data will be non-persistent (temporary data returned by a REST API). I could make the data persistable and use 2 database retrieves sorted by date (and retrieve only the first so I don't have to store the entire list in memory), but storing temporary data to the database would also hurt performance.

I'm now using a similar solution to your suggestion ('sort list by date, use head to obtain the correct object, then sort again in reverse'). I also clear the sorted lists after obtaining the object to reduce memory footprint. However, I can imagine that performance will still be hurt in case of a big dataset returned by the API. I will have to run more tests to see which of these options work best.

Joost

Created

Joost,

Currently, you can sort a list (by the datetime attribute) or retrieve the list sorted from the database (depending on how big the list is, database retrieve can be faster than sorting the list in the microflow).  Once you've got the list sorted, you can use List Operation Head to get the first item in the list.  So you could sort ascending - get the Head which would be your min date, sort descending - get the Head which would be your max date.  The list operation you describe would let you do that in one action, but the approach I have outlined is pretty quick and concise.

If I have misunderstood your idea, let me know.

Mike

Created