Power Automate - set filename by variable in Add row to Excel action

Brass Contributor

 

I have a Form for employees. One text field is department name.

I add the survey row into a particular department excel workbooks on sharepoint, i.e.

Covid-mp.xlsx

Covid-odsh.xlsx

Now I use switch to select the way with particular excel workbook and I select the workbook manually in the folder icon of the action field in every case.

But there are many departments, is it possible to set the excel file by variable in the "add row to excel" action?

Covid-<department>.xlsx

Zdenek_Moravec_0-1614924116260.png

Thank You

6 Replies

@Zdenek_Moravec no it's not possible because the Add a row into a table action won't know which table columns to add to the action when you are building the flow so you will always get an error when you try to save it. You can copy the action to your clipboard and then add it to each switch case, but you will need to change the file in each case.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

Hello @RobElliott 

OK, I see now, the manually selected file in the field "File" triggers the list of tables in the next field "Table". BTW, the option Add dynamic content in the field "File" is then useless, isn't it?

Anyway, I have created 16 more cases.

Copy the action is a good idea, but it does not work in my case - "Failed to find xxx in definition" (I have copied the Excel action in Case 2, created next case, clicked new action and selected My Clipboard)

Zdenek_Moravec_1-1614971850472.png

 

 

Hi @Zdenek_Moravec 

I might be too late if you've already gone another route, but this post and video by John Liu might help you use dynamic Excel file names... I've used these methods to add rows to Excel files which have a different name on each flow run. It's a little advanced, using SharePoint http requests, but it's quite cool once it's working!
Please see https://johnliu.net/blog/2019/5/workarounds-needed-to-use-the-excel-connector-in-microsoft-flow and https://www.youtube.com/watch?v=64lSykOYmzI
Hope this helps!

Sandy

Paste the action outside the Switch case then drag it inside.

Hello @Sandy Ussia 

Thank You for the link. The guide is really very advanced to me. I will stay by the basic level and I will study this guide once I get more advanced skills in power automate ;)

@RobElliott, thank You for the magic touch :)