Search code examples
excelpower-automateexcel-tables

Choose table to add a row to in power automate


enter image description hereenter image description hereI'm very new to power automate and I'm looking for a way to add rows to a specific table on a spreadsheet based on forms submission. For example, if the form comes from a specific city, I want to update that city's specific sheet and table in the excel file. I have about 25 sheets with 1 table in each sheet in the excel file and would like to be able to have a way update each table based on the city. I've created a condition that allows me to add a row to a specific city's sheet in my excel file but I don't want to have to do this for all 25 city's in my file. Is there a more efficient way to do what I'm trying to accomplish? Any help with this would be great!


Solution

  • So what you need to do is use the dynamic nature of the Add a row into a table operation/action.

    Note: This assumes that your columns are the same across each worksheet.

    As you know, when you select the table directly, you're presented with a list of columns ...

    Normal

    ... but if you want it to work dynamically, you'll need to first specify a table name dynamically and then fill the columns using JSON, like thus ...

    Dynamic

    You can see, I have a parameter called City Name and when the user types in Melbourne or Sydney, it will use the appropriate table name in order to populate said table.

    So if you haven't already worked it out, there is a table for each city and the name of each table is the city name.

    You can then see I have to specify the JSON manually (as such) as it needs to line up with the names of the columns.

    Spreadsheet

    It will all then work for you.