Search HoldMyTwist

Browse all posts

Remove duplicate tags from an array in Make

Use deduplicate on Make Free to get rid of duplicate tags. Note case and null. Also, why this does not stop repeat runs.

Repeated ceramic tags passing through a brass gate into a row of distinct shapes

You can easily add duplicate entries in a list before you pass it to the next step. To remove duplicates in an array of values, use Make's deduplicate function. It will eliminate duplicate values from the same array. The example below also indicates which values are not impacted.

Make's deduplicate function clears duplicate entries from a single array.

Before you start

You can create your make free account (opens in a new tab) or log in. No need to connect another app. Leave practice scenario Inactive Choose Run once.

1. Create a list with deliberate repeats

  1. go to Scenarios > Create scenario
  2. top left give it a name. let's call it "Unique tags practice"
  3. add module JSON > Parse JSON. don't put anything in Data structure. Paste in the existing example given right below these steps in the JSON string.
  4. Save the module/scenario (only hit Save anyway if it gives you a warning for not using the output. but don't worry about that)
  5. Hit Run once then Run anyway for that warning. Now look at the tags array in the source.
Text to copy

{"tags":["sale","new","sale","Sale",""]}

Full Make editor with a tags array containing a repeat, a case difference and an empty value

Full Make editor with a tags array containing a repeat, a case difference and an empty value
Open full-size image

2. Apply deduplicate to the whole array

  1. Hide results panel, on the right of JSON click on + and select Tools > Set variable
  2. In Variable name type unique_tags
  3. In Variable value copy-paste the expression below. Make sure that tags token is colored from JSON module 1. (if you source is using different number - replace with mapping panel token)
  4. Save module and scenario
Text to copy

{{deduplicate(1.tags)}}

Full Make editor applying deduplicate to the full tags array

Full Make editor applying deduplicate to the full tags array
Open full-size image

Watch out

This will just clear duplicates of current array. It won't keep tags from previous run and won't stop from making duplicate record in the future making the record twice. As you can see sale and Sale is still separate and even empty is still there.

3. Check what remains

  1. click run once
  2. click on the Tools result bubble. In the output expand unique_tags
  3. look at the four results (sale,new,Sale and a blank value)

Full Make editor showing sale, new, Sale and an empty value after deduplication

Full Make editor showing sale, new, Sale and an empty value after deduplication
Open full-size image

I'm cutting the 2nd sale. Capitalization and empty value cleanup is separate. If you want your workflow to consider sale and Sale the same tag, change all tags to the same letter case (https://holdmytwist.com/guides/make-clean-text-trim-lower/) before removing duplicates.

If the result is unexpected

Did you send in the complete tags array, not just the first element or a string with a comma separated list? (using simple text values in the example). If the array is of objects, make the Make docs distinct using a key that you can compare a specific property. Care about selecting the key. See what record stays when you investigate before trying to use customer data.

If you just want a cleanup once, you might want to use a spreadsheet. Be sure to review the Free-plan limits first before scheduling this in Make.

Source: Make array functions (opens in a new tab) (see screenshots using fake practice data).

Share this post