There are probably several way to do that, but I’d try this:
- you have your list with 30 objects, sort it on the value you’re calculating with and call that list30
- create a new empty list, let’s call that list20
- create an integer variable counter with value = 0
- loop through list30, add 1 to counter, if counter <= 5, continue, if counter > 20, break, else add iteratorObject to list20
- after the loop, you have your 20 objects in list 20 and you can do max, min and avg with the aggregate list action
Hi Muahmmad,
*To find maximum of 5 data, create microflow and retrieve desired entity. While retrieving data kept range as custom and in amount give 5 and in sorting choose the data attribute and sort it in descending and return the value.
*To find minimum of 5 data, follow the above steps in sort tab alone give Ascending.
*To calculate Average, retrieve all maximum and minimum data from the appropriate entity and then create a list.
*create two integer variable with initial value as 0 and in the loop take max retrieve list and iterate the loop, put decision check if the value is greater than or equal to 5 then add the iterator value to created list else just increase the variable by 1. Follow same procedure for minimum add the iterator value in same created list.
*using aggregate list action count the created list. To find total create a variable and initiate value as 0 and kept a loop inside that add the value and store in variable. Then divide (total value /count ) you will get average.
Hi Muahmmad,
Have a look at this module this will help you out: https://marketplace.mendix.com/link/component/117075
Then you can use Default Activities to perform the other operations.
I am not able to see the image ( it broken )
ATB
You’re using v8 which might require some utilities from the marketplace to complete the task like other answers have said.
For anyone using the latest LTS who comes across an issue like this again, with 9.24.0:
Hi Muhammad, I believe there are Java-actions that can achieve what you are describing. They can take a specified number of items from the top of a sorted list. Alternatively you could loop an ascending list for the min values where you remove the top item from the list for each iteration. Do the same for a descending sorted list for the value to remove the max values. You are then left with the 20 remaining middle values.