Filter to show only first items with a given value?

Hi! I'm new to Metabase and loving it so far, but still working on understanding "the Metabase way" of doing some things.

How can I:

  • run a query
  • sort the results
  • flag the first record with a unique value in column x

For example, say I have a TV programming schedule. We have 100 different programs, each of which are broadcast throughout the month. Each program has a unique identifier. In my database, I have a row/record for each individual broadcast. So, if an episode of "Friends" airs 5 times that week, it will have 5 rows, but each with the same program ID.

So I'd like to query to get ALL the episodes of, um, "Friends," sort them by date, then, by looking at the program ID, identify the first airings and flag them as such — say by setting a custom column of "first_airing" to TRUE or FALSE.

How could I approach doing this with Metabase? (Maybe this uses custom expressions?)

Many thanks!

Hi @smurray
I don't think the Custom Expressions are powerful enough for something like that currently.
You would have to do some modelling with your fingers (SQL) - have a read here:
https://www.metabase.com/learn/building-analytics/sql-templates/sql-cte.html