cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Derek4
Resolver I
Resolver I

extract first N of array variable and write to word template

Hi all,

 

I need to extract excel content and write to word template, I use an array variable to store all the excel content:

微信截图_20210412205736.png

 

Let's say there are total 50 set of data, How can I get the first 10 set to a word template, then the second 10 set to another word template, and so on...

 

I can't even find the array variable in the dynamic content:

 

微信截图_20210412210210.png

9 REPLIES 9
Pstork1
Most Valuable Professional
Most Valuable Professional

If you create an integer variable as a counter you can use a Do Until loop to access each value by index and increment the counter.  exit the loop when you reach the number you want to process.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi @Pstork1 ,

 

I did as you suggested, but I don't know how to "access each value by index", can you please share a screenshot or a formula that I can refer to?

 

Thank you!

 

微信截图_20210413085332.png

 

 

 

 

Pstork1
Most Valuable Professional
Most Valuable Professional

Here's an example.  I created an array with 3 nested arrays.  Then created a variable to hold the loop count and an array variable to build the target array in.

image.png

Then its just a DoUntil loop that appends the values as objects into the target array using JSON notation and indexing.  I'll show you that formula in a minute.  Then increment the counter variable.  The Do Until loop will loop until the count is equaled or exceeded.

image.png

The JSON for the values is typed into the Expressions tab.  It looks like this.

outputs('Car_Array')[variables('LoopCount')][0]

Outputs('Car_Array') is the name of the array.

the first index in square brackets is variables{'LoopCount') Thats the index of the row being processed.

The second index in square brackets is [0].  Which is the first field in the row of the first record, etc.

Its essentially the same notation as Array[0,0] in regular programming.  Its just in JSON.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi @Pstork1 ,

 

I tried your way, but it gives me an error:

微信截图_20210413115538.png

 

this is how I write the expression:

微信截图_20210413120005.png

 

outputs('varLabel')[variables('varCount')][6]

 

this is how my flow looks like:

微信截图_20210413115157.png

Pstork1
Most Valuable Professional
Most Valuable Professional

You only use the second square bracket if the record is an embedded array.  Since you are reading from Excel I assume you are reading rows of records. In that case the second square bracket would be the name of the field, not a number.  You also can't use the same varCount for two different loops because the value will already be set by the time you get to the second loop.  Can you provide a copy of one of your records that you are trying to read?  Without seeing your data I can't be more specific about what the JSON would look like.  For example, in your case the array is coming from a List Rows action in my case the array is coming from a Compose statement.  The pattern will be the same but the details will be different.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 ,

 

Thanks for your reply, this is how my Excel looks like:

微信截图_20210413203215.png

Pstork1
Most Valuable Professional
Most Valuable Professional

I wanted to see the JSON representation, not the actual file.  Can you just screenshot the output of the List Rows action output from a run?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 ,

 

it's like this:

{"statusCode":200,"headers":{"Pragma":"no-cache","Vary":"Accept-Encoding","x-ms-request-id":"7b31cc6c-e032-4b46-9812-0bf7f9c7c7c1;d6cccfc3-bc95-45c7-91ca-17254dc269e4;b1c439b5-ae1d-4d0d-a972-876d74c1c073;959064b9-3ec6-4927-ae5f-019590970d52","OData-Version":"4.0","Strict-Transport-Security":"max-age=31536000; includeSubDomains","X-Content-Type-Options":"nosniff","X-Frame-Options":"DENY","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"true","Cache-Control":"no-store, no-cache","Date":"Mon, 12 Apr 2021 05:29:31 GMT","Content-Type":"application/json; odata.metadata=minimal; odata.streaming=true","Expires":"-1","Content-Length":"8295"},"body":{"@odata.context":"https://excelonline-eus2.azconn-eus2.p.azurewebsites.net/$metadata#drives('b%21Uqv4scLWhUCxTIXFq0dDNZTolsKe0WVPrF9cUwGbf7_l5s4dKmvcSI4CrdisPFxQ')/Files('01DMAUJE44RBUGB4JAARFKJNMZD3CVHQQA')/Tables('%7BD676BF65-08EC-4B04-8421-F077E9C3CDE1%7D')/items","value":[{"@odata.etag":"","ItemInternalId":"ad5ef697-7c37-422b-a534-5c229b307a2f","EAM NO":"90120010082","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"UNK","PURCHASE ORDER_x0023_":"900123456","WORK ORDER_x0023_":"123456","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"09e0648d-360c-47bf-9229-d729d82c09e6","EAM NO":"90120010083","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"ABC","PURCHASE ORDER_x0023_":"900123457","WORK ORDER_x0023_":"123457","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"3d5200ba-6683-47e7-b49c-9c62a532720a","EAM NO":"90120010084","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"DEF","PURCHASE ORDER_x0023_":"900123458","WORK ORDER_x0023_":"123458","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"3aad09ae-dd6b-4033-bfc4-a841813975fe","EAM NO":"90120010085","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"GHI","PURCHASE ORDER_x0023_":"900123459","WORK ORDER_x0023_":"123459","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"e1b23fb4-f676-449b-94c6-c38faf675344","EAM NO":"90120010086","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"UNK","PURCHASE ORDER_x0023_":"900123460","WORK ORDER_x0023_":"123460","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"9401dc14-2b4e-48c5-8f06-a224f00e536e","EAM NO":"90120010087","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"ABC","PURCHASE ORDER_x0023_":"900123461","WORK ORDER_x0023_":"123461","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"702a0327-4ff3-4a2b-9f71-4ecc8b43c2ac","EAM NO":"90120010088","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"DEF","PURCHASE ORDER_x0023_":"900123462","WORK ORDER_x0023_":"123462","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"9d88c328-2e94-4d6b-b0a4-793f3e864ca0","EAM NO":"90120010089","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"GHI","PURCHASE ORDER_x0023_":"900123463","WORK ORDER_x0023_":"123463","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"d54d6259-893e-4c73-825f-1b46d89b3f9a","EAM NO":"90120010090","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"UNK","PURCHASE ORDER_x0023_":"900123464","WORK ORDER_x0023_":"123464","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"b09682da-074a-4d0e-929b-5751fbf49ccc","EAM NO":"90120010091","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"ABC","PURCHASE ORDER_x0023_":"900123465","WORK ORDER_x0023_":"123465","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"e48e6e23-8366-4095-9e73-8a3b8b5828bc","EAM NO":"90120010092","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"DEF","PURCHASE ORDER_x0023_":"900123466","WORK ORDER_x0023_":"123466","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"218aa60c-d74c-4c7b-a52b-1c6d3f7e7662","EAM NO":"90120010093","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"GHI","PURCHASE ORDER_x0023_":"900123467","WORK ORDER_x0023_":"123467","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"39d7d00b-9d91-447f-967b-a6e92c1cfc04","EAM NO":"90120010094","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"UNK","PURCHASE ORDER_x0023_":"900123468","WORK ORDER_x0023_":"123468","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"294298e4-a92b-4bd1-b53e-58082aac5e61","EAM NO":"90120010095","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"ABC","PURCHASE ORDER_x0023_":"900123469","WORK ORDER_x0023_":"123469","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"52d2be84-fc23-4c21-9d0a-3da72da89b03","EAM NO":"90120010096","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"DEF","PURCHASE ORDER_x0023_":"900123470","WORK ORDER_x0023_":"123470","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"d811410c-a360-44fb-a255-20dc115f32d0","EAM NO":"90120010097","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"GHI","PURCHASE ORDER_x0023_":"900123471","WORK ORDER_x0023_":"123471","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"d6e6b053-f060-406e-bba8-f6f3a7cc37e9","EAM NO":"90120010098","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"UNK","PURCHASE ORDER_x0023_":"900123472","WORK ORDER_x0023_":"123472","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"8928ab4e-e291-434f-bb3d-98701cb92905","EAM NO":"90120010099","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"ABC","PURCHASE ORDER_x0023_":"900123473","WORK ORDER_x0023_":"123473","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"437d9502-9712-46c7-b514-fac436cc6be6","EAM NO":"90120010100","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"DEF","PURCHASE ORDER_x0023_":"900123474","WORK ORDER_x0023_":"123474","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"0251b6dd-ac06-4d28-9827-d0a182297d18","EAM NO":"90120010101","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"GHI","PURCHASE ORDER_x0023_":"900123475","WORK ORDER_x0023_":"123475","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"59aba1b5-198b-4b9b-9c9f-4760bafa73e2","EAM NO":"90120010102","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"UNK","PURCHASE ORDER_x0023_":"900123476","WORK ORDER_x0023_":"123476","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"4f7389bc-1ac1-48ac-8d8d-7cc92718fffd","EAM NO":"90120010103","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"ABC","PURCHASE ORDER_x0023_":"900123477","WORK ORDER_x0023_":"123477","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"5c12b9dc-7ded-4ff8-86df-e0d15cd8329f","EAM NO":"90120010104","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"DEF","PURCHASE ORDER_x0023_":"900123478","WORK ORDER_x0023_":"123478","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"50856b28-006c-49c1-bb7c-74940dc140ba","EAM NO":"90120010105","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"GHI","PURCHASE ORDER_x0023_":"900123479","WORK ORDER_x0023_":"123479","LOCATION":"SACKROOM"},{"@odata.etag":"","ItemInternalId":"c6cf9657-961c-4f96-9c90-b0c4141ccb08","EAM NO":"90120010106","DESCRIPTION":"Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m","MFR P/N_x0023_ ":"EVO5LH-1500-1.5mtr","MFR NAME":"UNK","PURCHASE ORDER_x0023_":"900123480","WORK ORDER_x0023_":"123480","LOCATION":"SACKROOM"}]}}
Pstork1
Most Valuable Professional
Most Valuable Professional

So an individual row looks like this.

 {
                "@odata.etag": "",
                "ItemInternalId": "ad5ef697-7c37-422b-a534-5c229b307a2f",
                "EAM NO": "90120010082",
                "DESCRIPTION": "Lever Type Hoist, PROLH Model, SWL 1500 KG, 1.5m",
                "MFR P/N_x0023_ ": "EVO5LH-1500-1.5mtr",
                "MFR NAME": "UNK",
                "PURCHASE ORDER_x0023_": "900123456",
                "WORK ORDER_x0023_": "123456",
                "LOCATION": "SACKROOM"
            },

 

That means the code would look like this for Description.

outputs('Car_Array')[variables('LoopCount')]?['Description']

Of course your array isn't Outputs('Car_Array').  But that is the pattern.  Other fields would just be different fieldnames.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (2,147)