cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AoLMatthieu
Frequent Visitor

Excel matching issue using PowerAutomateWeb

Hi guys, hope you are doing good,

 

Having the following issue:

 

I have ExcelFile1 with some weekly data in Table1

I have ExcelFile2 with some daily data in Table2

 

Both excel are differents, not the same document

 

I am trying to match and retrieve the lines where Column A of both is similar. Retrieve full info of these lines from ExcelFile1 and add to it one column from ExcelFile2

 

AoLMatthieu_0-1688476472351.png

 

Here is current flow:

 

-Foreach: it opens value of list lines in table1

-Foreach: it opens value of list lines in table2

-Compare when colum A from each document is similar

-Add the infos into a table variable

-Then I create a new document with a new table that have the data from there

 

 

Any Idea how to make it work ? Am I approaching it wrongly ?

 

Thanks,

9 REPLIES 9
rzaneti
Super User
Super User

Hi @AoLMatthieu ,

 

Based on your description, this is a possible approach to achieve your goal. However, it is not clear where exactly you are finding the error. 

 

To identify the source of the error, I ask you the following:

  • Do you know which action is causing the error to your flow? If yes, please share the raw outputs from the action. If not, please share the raw inputs from your 'Ajouter a la variable de tableau', and confirm if the 'TableauFinal' variable is for data type 'Array'.
  • Do you currently have any other actions after your loops? If yes, please 

 

To access the raw inputs/outputs, you just need to go to the flow run page, navigate until the specific action and click in these buttons:

rzaneti_0-1688504541596.png

 

 

 

It will open a JSON view in a sidebar or in a new tab:

rzaneti_1-1688504541713.png

 

 

Find the "body" property (you can search it with Ctrl+F). Make sure to remove any sensitive content from the image before sharing it here 

 

If you still have any trouble to find the raw inputs/outputs, let me know and I guide you! Also, this article provides additional details about how does these raw inputs/outputs work and how to access them: http://digitalmill.net/2023/06/29/how-to-access-the-raw-outputs-in-power-automate/

Hey @rzaneti 

 

Thanks a lot for your answer,

 

The flow basically timesout while trying to get inside the first for each (which also seems limited to 256 entrance(my file has more lines than that)

 

AoLMatthieu_0-1688546351498.png

I can't really see where it struggles because of that

 

Thanks,

Hi @AoLMatthieu ,

 

Thank you for the image. Apparently you are receiving a 'timeout' when looping your tables. 

 

As a first idea to try to solve the problem, try to change the concurrency control from your loops. You can find this option in the "settings" from your 'Apply to each' action (it will make your loop iterations run in a non sequential way):

rzaneti_0-1688557677346.png

rzaneti_1-1688557773935.png

 

 

You will find more details about how to do it in the accepted answer from this post: https://powerusers.microsoft.com/t5/Building-Flows/Apply-to-each-Timeout/td-p/539959 .

 

I also found this community post about it (https://powerusers.microsoft.com/t5/General-Power-Automate/Flow-timeout-on-apply-to-each/td-p/207403... ), and the conclusion is basically that you have some limits for the 'apply to each' action depending on your Power Automate license. I know that one of your tables has 247 records; how many records has the other one?

Hey @rzaneti 

Thanks for your answer, i did the settings change but seems like it still doesnt work for the same issue

 

My documents do have 922 and 208 lines. Do you think there would be an other way to achieve what I am trying to do ?

 

Many thanks,

Hi @AoLMatthieu ,

 

A possible solution is the 'Office Scripts'. The Office Scripts are a JavaScript library that allows you to manipulate Excel and read/write data on it. It is similar to VBA, but for Excel Web. 

 

We can try to build a Script to add this extra column to your Excelfile1 to Excelfile2. To achieve it, please share a small sample with fake data from your table in Excelfile1 and your table in Excelfile2. This samples can have ~3 rows each... is just to understand the used data types and run the tests with a scenario close to the reality (in my environment, I will generate more rows in the same format from your sample, to achieve the approximated size of your tables).

AoLMatthieu
Frequent Visitor

Hey @rzaneti 

 

Sorry for late answer, summer period :s 

 

I tried to create the following script but it aint working : 

 

Excel.run(function (context) {
  //open files
  var file1 = context.workbook.application.workbooks.open("pathfile1.xlsx");
  var file2 = context.workbook.application.workbooks.open("pathfile2.xlsx");

  // get worksheet of files
  var sheet1 = file1.worksheets.getActiveWorksheet();
  var sheet2 = file2.worksheets.getActiveWorksheet();

  // column range i want to compare between both documents
  var range1 = sheet1.getRange("H:H");
  var range2 = sheet2.getRange("H:H");

  // load data
  range1.load("values");
  range2.load("values");

  return context.sync().then(function () {
    // comparison
    var data1 = range1.values;
    for (var i = 0; i < data1.length; i++) {
      var value = data1[i][0];

      // check if it exists
      if (value !== "") {
        var existsInFile2 = false;
        var data2 = range2.values;
        for (var j = 0; j < data2.length; j++) {
          if (data2[j][0] === value) {
            existsInFile2 = true;
            break;
          }
        }

        // if exists, copy and paste into do3
        if (existsInFile2) {
          var rowToCopy = sheet1.getRange("A" + (i + 1) + ":Z" + (i + 1));
          var destinationRange = file1.worksheets.getItem("Sheet1").getRange("A1");

          // 
          rowToCopy.copyTo(destinationRange);

          // path3
          var file3Path = "pathfile3.xlsx";

          // save file3
          return file1.saveCopyAs(file3Path).then(function (file3) {
            // add infos of additional column
            var sheet3 = file3.worksheets.getActiveWorksheet();
            var range2B = sheet2.getRange("L:L");
            range2B.load("values");

            return context.sync().then(function () {
             
              var data2B = range2B.values;
              var columnBValues = [];
              for (var k = 0; k < data2B.length; k++) {
                columnBValues.push([data2B[k][0]]);
              }

              // add the new column at the end of the document of file3
              var usedRange3 = sheet3.getUsedRange();
              var lastColumn = usedRange3.getLastColumn();
              var destinationRangeB = usedRange3.getCell(1, lastColumn + 1);
              destinationRangeB.values = columnBValues;

              // save
              return file3.save();
            });
          });
        }
      }
    }

    // Close
    file1.close();
    file2.close();

    return context.sync();
  }).catch(function (error) {
    console.log(error);
  });
});

Having errors : 

See line 3, column 7: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 4, column 7: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 7, column 7: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 8, column 7: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 11, column 7: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 12, column 7: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 20, column 9: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 22, column 11: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 27, column 13: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 37, column 15: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 38, column 15: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 49, column 17: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 50, column 17: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 55, column 19: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 62, column 19: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 63, column 19: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 64, column 19: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

See line 56, column 19: Office Scripts cannot infer the data type of this variable. Please declare a type for the variable.

 

 

Document look like this (attached). Document2 would look like the same with some ID in common, not all, rest of the data would also be the same, only spend column would be different

 

I take then the common lines (I use column campaign ID to compare) and put them in document 3, I add a new column to the document which is = to the column spend from document 2 (and of course it goes on the line with the correct ID)


Hope that's this is clear... if not let me know

 

Thanks a lot !

Hi @AoLMatthieu ,

 

I'm not sure if your approach with Office Scripts will be suitable to run integrated with Power Automate. Are you storing and running this script in the Excel Code Editor?

 

Some days ago (after your post), I answered another post here in the community with a partially similar problem: the user needed to collect data from an Excel file and use it in another. This is not the exact same problem as yours, but you can leverage the steps that we took there to extract data from your 2 files and insert it into the final file. 

 

This is the post: https://powerusers.microsoft.com/t5/Building-Flows/Compare-2-excel-and-highlight-the-row-with-differ...

 

Let me know if it works for you. I believe that you can use part or the code that you sent above in this new approach. 

AoLMatthieu
Frequent Visitor

Hi @rzaneti 

I run the script from power automate and I store it in the excel code editor, this has been working for other scripts I have done, why shouldn't it there ?

 

Going to check it out !

Thanks,

Hi @AoLMatthieu ,

 

Your method is correct: you can call a script written in the Excel Code Editor from Power Automate. But the Script has some limitations, and it needs to have a main function, for example. I saw that you are using an Excel.Run method - which is used in the Office Add Ins -, but for manipulating the Scripts inside Excel Web and call them via Power Automate, you technically cannot use it. 

 

In summary, the logic of your code seems to be perfectly correct, but some small changes will be needed to fit it to the Office Scripts.

 

I'm sharing with you two articles about the basic use of the Office Scripts and its difference from the 'Add-Ins':

https://learn.microsoft.com/en-us/office/dev/scripts/resources/add-ins-differences

https://learn.microsoft.com/en-us/office/dev/scripts/develop/scripting-fundamentals

http://digitalmill.net/2023/06/19/get-started-with-office-scripts/

 

 

Helpful resources

Announcements

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!    

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS   Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!   Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!       Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!   UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!   European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!     Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!     For more events, click the image below to visit the Microsoft Community Days website.      

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!

Users online (3,943)