Map an IMDb Genre list to a "Genres" table

I am using the IMDb pack to manage my videos. This handy pack creates a column of comma delineated genre tags I named “IMDb Genre List”. I want to map this list into a separate lookup table called “Genres” as shown below…

For this screenshot, I manually selected the Genres… How do I get coda to do this for me?

1 Like

Hey Alan, thanks for reaching out! If you want to map a list of text values to Lookup values, I think you should be able to set the row with a formula like thisRow.IMDb Genre List.

If that approach doesn’t work, you can use a filter argument and an automation or button formula that will map the correct row references for each blank row in your Genre column from the text list in your IMDb Genre List column.

For example, the button formula I had in mind goes something like this:
Videos.Filter(Genres.IsBlank()).FormulaMap(
WithName( CurrentValue, CurrentRow,
[Genres], CurrentRow.[IMDb Genre List].FormulaMap(
Genres.Filter(Genre = CurrentValue)
)
)
)

Let me know if that gets things going for you!

Hi @Alan_Larsen1 - I’m the creator of the Pack, glad you’re enjoying it!

This took me a bit of hacking to get right, but here’s the formula that worked for me:

thisRow.[IMDb Genre List]
    .Split(", ")
    .ForEach(
        GenresTable.Filter(GenreName=CurrentValue)
    )
   .ListCombine()

So what the heck is going on here? Mostly a whole bunch of stuff to massage things into the type of data Coda is expecting at each stage. Let me break it down:

  • .Split(", ") - The list of genres is just a bunch of text; Coda doesn’t realize it’s a list. To convert it to a true list in Coda’s mind, we need to take that text, and split it up into separate items anytime we see ", " (a comma followed by a space)
  • Now we’ve got a list! Let’s look at each item in the list individually with forEach()
  • For each of these items, we want to match it to the corresponding record in our Genres table (GenresTable.Filter(GenreName=CurrentValue), where CurrentValue is the current item from that list we created, and GenreName is what I called my display column in my Genres table)
  • You’d think this would be enough lol, but the result comes out as [Action], [Drama] instead of Action, Drama, so we need to go one more step further and say “hey, everything that the ForEach function spits out? I want you to mash that all into a Coda list using ListCombine()” (because when Coda is asking you for multiple lookups, it’s asking you for a list of those lookups)

Phew! Maybe someone can come along with a more elegant solution (most of this is Coda fundamentals, not IMDb-Pack-specific), but in the meantime, this should work.

Also, curious about your use case! I’m always interested to hear what people are doing with the Pack.

Edit: Instead of ListCombine(), you could add .First() at the end of GenresTable.Filter(GenreName=CurrentValue). Up to you. The problem is that Filter() always returns a list, even if it’s a list of 1. You can either combine those lists together with ListCombine(), or force Filter() to return only the first (and usually only) item with .First()

*Edit2: In retrospect, I probably could have designed the Pack to spit out a list of text objects, not a single text object with commas in it. I might change this. If this formula breaks on you in the future, the solution will be to remove Split() (cause I’ll be doing that for you in the Pack)

This works perfectly - thanks so much for the ideas and the detailed explanation!

I wanted to map this so I can add a formula in genre table to easily see which movies are in each category. Now I know all my action movies, etc. Thanks for making this pack - its super helpful!

1 Like

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