How can I keep only the last entry when multiple objects have the same "hora" and "fecha" values?
For example, in the following list, all three objects share the same "hora": "12:00" and "fecha": "16/04/2025". I want to keep only the last one and remove the earlier duplicates:
This kind of logic is actually pretty tough to build in MAKE.
This was actually really challenging and fun to do
You need to:
Dynamically identify which hora values are duplicated.
Isolate and keep only the last bundle for each duplicated hora.
Merge those with the entries that are already unique.
Handle multiplehora values with different estado entries — not just a one-off case.
It’s not something MAKE handles natively, so it takes a lot of routing, mapping, and variable juggling to get it right.
Step-by-step logic:
1. Parse the original JSON
Used the Parse JSON module to bring the array into MAKE for processing.
2. Aggregate all entries
Collected every object using a Basic Aggregator, so I could work on the full array later.
3. Get distinct hora values
Created a variable (deDup) using distinct(...) to identify all unique hora values.
4. Count how many times each hora appears
Used map(...) to simulate a frequency map, allowing me to differentiate between duplicated and unique hora entries.
Routing Logic:
A. If a hora occurs more than once (duplicate):
Filter entries by that hora
Aggregate them to preserve order
Use last(...) to extract the final occurrence
Use __IMTINDEX__ to find the actual object from the original array
Store this as part of a variable: All last horas
B. If a hora occurs only once (unique):
Filter the array by hora values with a count of 1
Aggregate those untouched
Store this as: All unique horas
Final Step: Merge results
Used merge(...) to combine:
The last duplicates (All last horas)
The already unique entries (All unique horas)
Stored the final result in a merged variable.
Result:
An array that:
Keeps only the most recent entry for each duplicated hora
Preserves all uniquehora values
Is fully dynamic, works across any number of hora + estado combinations
I essentially built two new array. One with the non duplicated horas and one with which we account for the possibility of more than one duplicate the example you sent only had one. But I assumed in the future you will have more. Then we merged these back together.
@Mr.Make Great Solution. but one thing it takes lot of operation in make.com. Is there is anyother option to get the same step? Like Openai Or any other?
Usually to optimise and reduce the amount of operations, the most common way is to use a module that can run JavaScript, Text Parser, and string functions.
If you require further assistance, my profile has a couple of links to resources that may help, or you can search my previous posts on my profile for answers to similar questions like these.
Hope this helps! Let me know if there are any further questions or issues.
@samliew Thanks for the message but i have not found any usefull link. the Javascript required the API which is paid.
How I can use text parser to generate the Json output.
or Openai?
You can also use the Hire a Pro category to request for private 1-to-1 assistance via video call/screenshare/private messaging/etc. This may help you get your issue resolved faster especially if it is urgent or contain sensitive information. It is important to post your request in the Hire a Pro category, as forum members are not allowed to advertise their services in other categories like here (even if it’s free/unpaid). Posting in the Hire a Pro category will allow other members to assist you over other forms of communication.
Alternatively, you can use the private messaging feature to directly reach out to other forum members. To do this, go to your profile, and click on the “New Message” button:
Hope this helps! Let me know if there are any further questions or issues.