title: How can I look up words in a cell and add multiple labels accordingly without duplicates?
body: <p>I am trying to label data rows with pre-defined locations. I am not sure if it is possible with Excel functions, or if a script is required.</p>
  <p>The data comes from a free text input field and sometimes contains locations that I am specifically looking for. I then want to add labels to a cell if the input contains one of my locations. Those should be separated by semicolons and not contain duplicates.</p>
  <p>Let me give you two examples:</p>
  <p><strong>Input cells</strong></p>
  <p>These are the two example inputs that I want to search for locations so that I can add labels.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>#</th>
  <th>input text</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>Tulum, Madrid and Rome</td>
  </tr>
  <tr>
  <td>2</td>
  <td>I am looking for an offer in Berlin and the Alps or Vienna</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>Labels</strong></p>
  <p>I now have a long list of locations and associated labels which I am looking for:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>location</th>
  <th>label</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Austria</td>
  <td>Vienna</td>
  </tr>
  <tr>
  <td>Austria</td>
  <td>Alps</td>
  </tr>
  <tr>
  <td>Germany</td>
  <td>Berlin</td>
  </tr>
  <tr>
  <td>Italy</td>
  <td>Rome</td>
  </tr>
  <tr>
  <td>Mexico</td>
  <td>Tulum</td>
  </tr>
  <tr>
  <td>Spain</td>
  <td>Madrid</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>The original list is quite extensive and around 80 labels long.</p>
  <p>Now I want to add the locations as labels in one cell behind the input without duplicates. #2 would be a duplicate with Austria twice, I only need it once. If this is the make-or-break, duplicates might also be possible.</p>
  <p>The output should look something like this:</p>
  <p><strong>Output</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>#</th>
  <th>input text</th>
  <th>labels</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>Tulum, Madrid and Rome</td>
  <td>Mexico; Spain; Italy</td>
  </tr>
  <tr>
  <td>2</td>
  <td>I am looking for an offer in Berlin and the Alps or Vienna</td>
  <td>Germany; Austria</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Now, is there a way to do this via Excel (Google Sheet) Functions or do I need to write an Apps Script to add the labels?</p>
  <p>I tried to solve it with a lookup but as far as I know, that can only give me one of the labels and not multiple…</p>
  <p>I appreciate any ideas or hints! Thank you in advance! :)</p>