cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Create Expression form user input/variable

Hi everyone


I'm in the middle of building a flow, but somehow I'm not getting it right. Maybe you can help.


Idea of the flow

User will provide:

  • an Excel-File
  • and the name of the column that needs to be extracted from a table -> variable VarStrExpression

the flow then

  • extracts the named column (stored in VarStrExpression) form the table
  • and afterwards does something with the extracted data in dataverse. e.g. update the record with the same Titel/or better an ID

Inside the flow I get all rows of the excel file into an array. column names Titel, Ist, Problem, ...

ArrayArray


Lets say, I want to extract the column "Titel" from this array, I can do it with a Select action

2021-06-01_17h26_03.png

It all works fine if I hard code the column/property name in the items expression as item()?['Titel']

2021-06-01_17h27_03.png

 

But how do I change the item expression dynamically based on the column name provided by the user / stored in a variable. Is that possible?

 

I tried the following expressions:

  • item()?[string(variables('VarStrExpression'))]
  • item()?[variables('VarStrExpression')]
  • item()?['variables('VarStrExpression')']

They either result in empty array values or in errors when trying to save the flow.

 

Any help to get this running is appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User
Super User

Hi @Anonymous 

 

Because its an array you need to specify the For Each Loop in your expression. Please see below

 

image.png

image.png

 

Above expression is as follows:

items('Apply_to_each')?[outputs('Compose_3')]

 

My Test Result

 

image.png

 

image.png

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

3 REPLIES 3
abm
Super User
Super User

Hi @Anonymous 

 

Because its an array you need to specify the For Each Loop in your expression. Please see below

 

image.png

image.png

 

Above expression is as follows:

items('Apply_to_each')?[outputs('Compose_3')]

 

My Test Result

 

image.png

 

image.png

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
Anonymous
Not applicable

@abmThanks for your reply. You solved my problem partially. The for each was not necessary. The "Select" action does work and usually works faster than "for each".

But instead of "variable" I used "compose" as you suggested, and now it works just fine.

Anonymous
Not applicable

I use "select" to extract the column from a excelfile. The flow user has to name the desired column previously. The input given by the user is passed to a compose action and the compose result in the select action.

 

2021-06-28_08h11_04.png

 

 

2021-06-28_08h11_23.png

 

Helpful resources

Announcements
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.

Power automate tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Users online (2,208)