In Vega, Filter one data table by another data table's contents

Hello,

I am trying to determine how I could filter data tables based on another tables contents.

e.g. Lets assume I have two tables; Table A that has items 1,3,5, and 7 in it.
and Table B that has items 1,2,3,4,5, and 7 in it.

How can I filter these two tables such that I get a list of items that are either not in both or only in both?

Thank you!

I believe this is what you are looking for.

{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "data": [
    {
      "name": "first",
      "values": [
         {"number": 1},
         {"number": 3},
         {"number": 5},
         {"number": 7}
      ]
    },
    {
      "name": "second",
      "values": [
        {"number": 1},
        {"number": 2},
        {"number": 3},
        {"number": 4},
        {"number": 5},
        {"number": 7}
      ],
      "transform": [
        {
          "type": "lookup",
          "from": "first",
          "key": "number",
          "fields": ["number"],
          "as": ["match"]
        },
        {"type": "formula", "as": "matched", "expr": "if(datum.match, 'only-both', 'not-both')"}
      ]
    }
  ]
}

image

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.