Create 2 Rows in a Table from a Single Row in another Table

I’ve seen a few posts floating around like this but it’s a deeper problem than I originally thought so I’m asking for some advice.

I have a table of sermons that I edit for a radio program that our church does. For each sermon I edit we have two radio programs from it. So I made a table of sermons to track my editing process, but I also want to have a table to track the process for radio programs, that is syncing to the original table. My original table has all the data the second table needs, like air dates and such, I just need to create 2 rows in the “episodes” table for every row in the “Sermons” table, and then I want to pull certain info into the episodes table based on the “sermons” table.

I think I’m lost on how to make 2 rows based on one row and keep everything tied together.

Hi Tyler

Can you share a copy of the document? It is extremely difficult to work in the air like this.

Regards
Piet

So here I’ve got a page for 2 views which let’s me track the next 60 days of things to do. Then a page for sermons that are ready to be edited. The “Episode Tracking” is the part I’m not sure about. I can do it by hand, but I’d like to make this automatically create the two “episode” row entries for every sermon. Preferably after I’m done editing would be great. Basically I want to automatically make two new rows one for each of the “air dates.” I also need to pull through some other info like the sermon title, and the passage but the part I was tripping up on was how to make the two rows from the single row and keep everything in sync.

Hey @Tyler_Collins. If you have one row and you want to create two rows in another table, you will need to use ForEach or a RunActions in a button. It will depend on what data you want to copy to each row. You mentioned that you have different data you want for each row, so a RunActions() might be the best option since you know you only want 2 rows. So you’d put RunActions(AddRow(table, column, data…), AddRow(table, column,data…)) Then in each of thoes AddRows you would put data you wanted to go into each row. Push that button either manually or with an automation and you’ve got your two rows. Now, if the data you wanted to go into each row was going to be more similar than different I’d consider using a Sequence() with a ForEach(). But if you are only going to do 2 rows every time, the first option is the easiest to understand and write.

Thanks for the reply! I think what I’m struggling with is how to get reference the specific row inside of my “ForEach()” loop. I feel close with the code below, but I know it will output every sermon title for each row name, rather than just outputting the sermon name once for each row. That’s the part I’m missing I think. If I can figure that part out I think I could get the rest done. Just missing that piece.

Looking at your example, I think I have the same problem, I want to copy specific info from each row so I’m not sure how to the “thisRow” in these formulas to get it do what I need.

 ForEach(
  db_Sermons.Filter([Edit Done] = true),
  RunActions(
    AddRow(
      [db_Table Test],
      [db_Table Test].[Sermon Title],
      db_Sermons.[Sermon Title],
      [db_Table Test].Part,
      [Part 1]
    ),
    AddRow(
      [db_Table Test],
      [db_Table Test].[Sermon Title],
      db_Sermons.[Sermon Title],
      [db_Table Test].Part,
      [Part 2]
    )
  )
)

I’ve updated my example with the code above. :slight_smile:

So for the doc above it would be:

 ForEach(
  db_Sermons.Filter([Edit Done] = true),
  RunActions(
    AddRow(
      db_Episodes,
      db_Episodes.[Sermon Title],
      db_Sermons.[Sermon Title],
      db_Episodes.Part,
      [Part 1]
    ),
    AddRow(
      db_Episodes,
      db_Episodes.[Sermon Title],
      db_Sermons.[Sermon Title],
      db_Episodes.Part,
      [Part 2]
    )
  )
)

Nevermind, I finally found the “currentValue” function. That’s exactly what I’m trying to do. I think I’ve got it now. :innocent:

@Tyler_Collins Yes, you can use the currentvalue then reference the items of that row using the “.” So currentvalue.property to get the various things. I’m guessing from your example that you have a canvas button that lives OUTSIDE your table. I usually will put my button INSIDE my table so it would act on “thisrow”, then I can call that button from somewhere else either a canvas button or an automation. I just find it’s easy to follow the logic when it’s in the table and you can do your testing one row at a time. Then when you get your button acting on that one row the way you want, you just have another button run all the buttons on the table by using tablename.butonname or if you only want the button to execute on certain rows tablename.filter(filter conditions).buttonname. Hope this helps give you some ideas.

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