How to Get the Last Value and remove the Similar Values

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:

[
	{
		"hora": "10:00",
		"fecha": "16/04/2025",
		"estado": "Ocupado"
	},
	{
		"hora": "11:00",
		"fecha": "16/04/2025",
		"estado": "Ocupado"
	},
	{
		"hora": "12:00",
		"fecha": "16/04/2025",
		"estado": "Ocupado"
	},
	{
		"hora": "12:00",
		"fecha": "16/04/2025",
		"estado": "Libre"
	},
	{
		"hora": "12:00",
		"fecha": "16/04/2025",
		"estado": "Libre"
	}
]

Expected output:

[
{
		"hora": "10:00",
		"fecha": "16/04/2025",
		"estado": "Ocupado"
	},
	{
		"hora": "11:00",
		"fecha": "16/04/2025",
		"estado": "Ocupado"
	},
  {
    "hora": "12:00",
    "fecha": "16/04/2025",
    "estado": "Libre"
  }
]

@Mr.Make @samliew Can you please help me with this

This kind of logic is actually pretty tough to build in MAKE.

This was actually really challenging and fun to do :slight_smile:

You need to:

  1. Dynamically identify which hora values are duplicated.
  2. Isolate and keep only the last bundle for each duplicated hora.
  3. Merge those with the entries that are already unique.
  4. Handle multiple hora 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.

:wrench: 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.


:shuffle_tracks_button: Routing Logic:

:motorway: A. If a hora occurs more than once (duplicate):

  1. Filter entries by that hora
  2. Aggregate them to preserve order
  3. Use last(...) to extract the final occurrence
  4. Use __IMTINDEX__ to find the actual object from the original array
  5. Store this as part of a variable: All last horas

:motorway: B. If a hora occurs only once (unique):

  1. Filter the array by hora values with a count of 1
  2. Aggregate those untouched
  3. Store this as: All unique horas

:counterclockwise_arrows_button: 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.


:white_check_mark: Result:

An array that:

  • Keeps only the most recent entry for each duplicated hora
  • Preserves all unique hora 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.

You also could easily solve this with a simple prompt to chat gpt or any AI or with scripting. But I wanted to do this in MAKE.

Here is the blue print.
blueprint (31).json (59.2 KB)

@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

1 Like

@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 run JavaScript for free using my free private module, which can be installed here Is there a way to count tokens?

Here is an example: Remove empty keys/variables from data - #8 by samliew

@samliew Okay thanks for sharing. then what is the javascript to solve the above problem?

Sorry, JavaScript is out of scope for this forum as it takes time to code.

But I can provide an example use of the module, which you can see here: Remove empty keys/variables from data - #8 by samliew

If you need further assistance,

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.

— @samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.