[SOLVED] How to filter on foreign keys?

I have configured an integer field as a foreign key to another table in the admin UI (organization_id -> organization). I suspect this part is correct, because I have also configured it to display friendly names via the foreign key and that works when I display query results as a table.

In the question builder (either metric or custom) I would like to filter on a field from organization, but I a) don’t see any fields brought in via the FK, or b) when I select the FK can only filter it as if it was just an integer.

The documentation suggests to me I should be able to do this:

You can filter by any field in the table you’re working with, or by any tables that are connected through a foreign key.

Any suggestions? Thank you!

Just tried on the Sample Dataset that comes with Metabase. Here’s a query on the Orders table. Similar to what you tried I set up the Product FK to display Title in place of ID. I noted that if I filtered on Product price with exact values with equal to I got nothing. Could make sense if it’s somehow sensitive to rounding errors or something. That’s why I set it to less than. When I afterwards added the Product Category Filter it reduced the resultset. Haven’t done anything else to validate though.

Hope you are able to replicate what I did with the sample dataset and then work from there.

This is with 0.30.4 freshly installed:

1 Like

This helped. I think everything was working fine, but I missed that I had to un-collapse the “Organization” to see fields from it (I was actually blind to the entire tab.) Working through it again on the sample dataset helped me notice this.

Thanks for your patient explanation and repro, I missed something pretty obvious here :confused:

1 Like