How to get counts of foreign key records as a column?

I am trying to figure out the best way to get a count of the foreign key table rows as columns that I can use in questions/queries.

Here is an example, I have a Profiles table.

When I click on a given record the counts I want are displayed. Any help or pointers are appreciated thanks!

Hi @Brandonlipman
Sounds like you're looking for "Number of distinct values of ..."

Thanks - But this does not exactly solve my problem. I loaded to example dataset for illustration and I think this should be possible using a Metric with a custom expression but I am getting this error.

I am using the documentation as my guide here but still unsuccessful. Thanks!

@Brandonlipman It’s not currently not possible to use Count as a function:
https://github.com/metabase/metabase/issues/11558 - upvote by clicking :+1: on the first post
As a workaround, since 0.35, you now have CountIf(...) among many other expressions, so you could try a little hack like:
CountIf([Orders.User_ID] > 0)

Thanks for the tip and upvoted. But getting this when I run your test.

@Brandonlipman Which version of Metabase are you using? You need to select the column - I just wrote whatever you had.