cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tagordon90
Regular Visitor

Nesting input variables inside of newly produced variables

Hello,

 

This project extracts/manipulates data from a variety of banking institutions, and I'm trying to streamline my code by utilizing input variables better.  Is there a way to nest an input variable inside of an action's newly produced variable?

 

For example, if I want to activate an Excel worksheet by a Name, I can set an input variable as "Bank", then, Bank = "Citi".  Now this gives me a dynamic element that allows for copying and pasting one line for each separate bank.  Worksheet name = %Bank + '_Raw'%.  This will activate the Excel worksheet "Citi_Raw".  When my Bank input variable is changed from "Citi" to "Chase", this code will then activate the Excel sheet "Chase_Raw". 

 

I'm trying to take this one step further by storing a variable in this same manner.  For example, if I'm using the action "Read from Excel worksheet", I'd like to store the variable as %Bank + "_DataStore"%.  However, this syntax will not work.  I've also tried %Bank%"_DataStore" and %Bank%+"_DataStore".  Am I just missing the correct syntax here, or is this not possible in PAD?    

3 REPLIES 3
MichaelAnnis
Super User
Super User

Hey Gordon,  to my knowledge, you cannot create a variable this way.  It is a limitation on most coding, and I hate it, because it seems so simple.  There are however options to get what you need.


Option 1 - Add Bank_DataStore to a list.  As it loops through, it will just keep adding to the list until the loop is over, and then you should be able to paste the list wherever you need to (I am not very familiar with the "how" on this, I just know it's doable in PAD.  For me, I haven't spent time on this, and I don't know how to recall from the list, so not having that knowledge, I would choose the next option.

 

Option 2 (my preferred option)  - make it part of the loop to change windows to a write file (I like Excel) where you need this data, and have it write the variable with an {Enter} at the end, so you make yourself kind of your own output file.  This can also be used as a reference file later.  So, if you need to recall this variable later, you can make it part of that loop to go to your write file and pull the data needed.

 

Best of luck.

Hey Michael,

 

Can you please elaborate more on Option 2?  I'm not really grasping the concept yet.  Thanks for your input!

So, I have a loop that goes to morningstar.com puts in a ticker symbol, and pulls the investment style, but I can't create a variable for %Ticker_Style% inside of the loop.  So instead, the loop itself has %Ticker% and %Style% that are both identified with each loop.  But let's say I have 100 tickers, and I need to recall specific styles for specific tickers in another loop later, once my first loop reiterates, %Ticker% and %Style% have been overwritten, so I need to save that data somewhere else for later reference.  This is where option 2 comes in.

In my first loop, I "Write to Excel" %Ticker% to column A and %Style% to column B.  So, at the end of my first loop, all %Ticker% are in column A and all %Style% are in column B.  Now when I am running my second loop, I can reference my write file for the needed data.  So, let's say loop 2 is running through a different set of tickers, but we want to see if the %Style% appears from the first loop.  In C1, "Write to Excel" =Vlookup(%Ticker%,$A:$B,2,False).  The result will be the %Style% for that ticker.  Then you can use "Read from Excel Worksheet" to pull the %Style% back into the new loop.

Hope this helps.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Top Solution Authors
Top Kudoed Authors
Users online (3,260)