web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to Update Columns ...
Power Automate
Unanswered

How to Update Columns of an Array within "Apply to Each"

(0) ShareShare
ReportReport
Posted on by

Summary

While inside an "Apply to Each" step, how do you update columns in the current row?

 

Detail

I have an array (from google sheets) that includes a column of date/time strings.  Since I can't find any method of converting a date/time string to the standard ISO 8601 format I've built my own expressions.  It's in a set of 13 "Set Variable" steps inside my "Apply to Each".  My plan was to have the final step in the "Apply to Each" be some form of Compose or something to Set items('Apply_to_each')['Date/Time Scheduled'] where 'Date/Time Scheduled' is the column with the non-ISO standard format.  I also tried adding an extra 'Standard Date/Time' Key in a "Select" before the "Apply to Each".  However I don't know how to update that field either.   Putting all the required expressions in the "Select" step is, I believe, not possible.

 

In case you want to see the long "Apply to Each".  

I don't think the details of what's in the "Set Variables" would help you with my question.

Paul_Iowa_0-1607120720564.png

 

Thanks!

 

 

Categories:
I have the same question (0)
  • Paulie78 Profile Picture
    8,422 Moderator on at

    I would go for an entirely different approach and not use any "set variable" actions at all.

    I would create an empty array outside of the loop and then within the loop I would have a single "Append to array variable" action, which adds a new entry to the new empty array. The compose would be comprised of a json object that has all of the expressions you are using in your "set variable" actions. Something like this:

    {
     "SDT": someExpressionHere,
     "SDD": anotherExpresssionHere,
     "SM": youGetTheIdea,
     "Dummy": itSoMuchCleaner,
     "SM 0 Prefix": toDoItThisWay,
     "SD": withTheExpressionsWithinTheCompose
     "Dummy 2": youWillGetANiceArrayOfObjects
     "SY": youCanGetOnWithYourLife,
     "Something Else": withoutAllThoseVariablesInIt
    }

     

  • Community Power Platform Member Profile Picture
    on at

    Hi @Paulie78,

    Thanks very much.  I've actually started with the "append to array" idea.  That seems to be working.  And my long set of "set variables" seems to be working as well but the overall "Apply to Each" is creating an error  "An action failed. No dependent actions succeeded."  I need to figure that out first.

    Paul_Iowa_0-1607133030215.png

     

    Also, I didn't know you could put expressions in JSON arrays inside compose.  Cool! I do like clean "code". I'll play with that and report back here.  I wonder if the expressions in your example can reference the "variables" in previous expressions.  Here is what I'll try from pulling together all my "set variables". It'd be nice to be able to put comments in there.  

     

    {
    	"SDT":@{items('Apply_to_each')['Date/Time Scheduled']},
    	"SDD":@{split(variables('SDT'),' ')[0]},
    	"SM":@{split(variables('SDD'),'/')[0]},
    	"Dummy":@{concat(if(equals(length(variables('SM')),1),'0',''),variables('SM'))},
    	"SM":@{concat(if(equals(length(variables('Dummy')),1),'0',''),variables('Dummy'))},
    	"SD":@{split(variables('SDD'),'/')[1]},
    	"Dummy":@{concat(if(equals(length(variables('SD')),1),'0',''),variables('SD'))},
    	"SD":@{concat(if(equals(length(variables('Dummy')),1),'0',''),variables('Dummy'))},
    	"SY":@{split(variables('SDD'),'/')[2]},
    	"Dummy":@{concat(if(equals(length(variables('SY')),2),'20',''),variables('SY'))},
    	"SY":@{concat(if(equals(length(variables('Dummy')),2),'20',''),variables('Dummy'))},
    	"ST":@{split(variables('SDT'),' ')[1]},
    	"SAP":@{split(variables('SDT'),' ')[2]},
    	"SD":@{concat(variables('SY'),'/',variables('SM'),'/',variables('SD'), ' ',variables('ST'),' ',variables('SAP'))}
    }

     

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    I've played with this idea and search enough to decide that, unless someone can prove to me otherwise, it is no possible to use a compose action to pack several set variables as @Paulie78  suggests.  

     

    So, the solution to the original question "How to Update Columns of an Array within "Apply to Each"" is you cannot.  The workaround is, as @Paulie78 recommends to build a new array within the "Apply to Each" using "Append to Array".  Then, after the "Apply to Each" use the new array.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard