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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Managing Datatables an...
Power Automate
Unanswered

Managing Datatables and Arrays in PAD for Enhanced Data Handling

(0) ShareShare
ReportReport
Posted on by 78

Here is a brief overview of what I am trying to achieve: extracting data from a PDF and matching the text in specific Excel cells, while also incorporating some logic. This step is necessary because, unfortunately, the text cannot be directly matched. In the invoice section listing the items, we have lines like : 

 

1312.124.222.001 10 10.50
8080.080.221.002 5 19.25
7070.321.111.003 1 25.43

where the last three digits of the item number (1312.124.222.001) signify the country of origin.

At the bottom of the invoice, the information is presented in separate rows, such as

Germany 001
Italy 002
France 003

For instance, 002 corresponds to Italy. I have created a datatable to store the invoice rows, for instance :

{['ItemN', 'Q.ty', 'UnitP', 'CountryO'], ['1312.124.222', '10', '10.50', '001'], ...}

 

I have already acomplished the first part of the logic using regular expressions, foreach loops, and other logic.

Next, I need to replace the country of origin codes in the datatable with the actual country names, like changing 001 to Germany, 002 to Italy, 003 to France, etc.

Now, I need a bit of help to finalize the logic in the simplest possible way.

Firstly, how should I proceed with the country of origin information? Would it be better to store them in another datatable like 

{['CountryCode', 'Country'], ['001', 'Germany', ...]}

and then use two foreach loops, the first to cycle through the first datatable, and after extracting the CountryO information, start a second foreach loop to search the second datatable for a match? If so, given that the previous information was in multiple rows like "Germany 001", how can I write them directly inside the datatable?

Do I need to split the text somehow, or what? It seems too complex, and I want to simplify it.

 

Any ideas?

I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Ronyn77 

     

    Try this approach of joining both datatables> it would do things faster 🙂

    see below

    suppose this is country datatable 

    Nived_Nambiar_0-1711475696101.png

     

    This is Invoices data which you have extracted.

    Nived_Nambiar_1-1711475728345.png

     

    Now use the below code in run .net action

    Nived_Nambiar_2-1711475778458.png

     

    References to be loaded> to get better idea on that, refer the below article on it. https://www.linkedin.com/pulse/how-run-net-script-action-empowers-data-table-power-automate-bysani/

     

    For input / output parameters  , this is how i have passed the parameters

    Nived_Nambiar_3-1711475963598.png

     

    The code should be like below

    dtoutput= dt1.Clone()
    dtoutput.Columns.Add("Country")
    Dim dtemp As DataTable
    dtemp= dtoutput.Clone()
    dtoutput=(From r1 in dt1.AsEnumerable()
    Join r2 in dt2.AsEnumerable() on r1("CountryO").ToString Equals r2("CountryCode").ToString
    Let ra= New Object(){r1("ItemN").ToString(),r1("Q.ty").ToString(),r1("UnitP").ToString(),r1("CountryO").ToString(),r2("Country").ToString()}
    Select dtemp.Rows.Add(ra)).CopyToDataTable()

     

     

    Overall flow looks like this

    Nived_Nambiar_4-1711475999264.png

     

    Running the flow gives me below results

    Nived_Nambiar_5-1711476016740.png

     

    I hope this is as expected !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If you get the countries and their Ids into a table, you only need to have one loop to iterate through this table. Then use Find and replace in data table to find and replace the Ids in your original data table with country names. It's quite straightforward and simple, and you can make the action target a specific column in your data table, to make sure it doesn't find matches for the Ids in other columns.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 261 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 185

#3
Haque Profile Picture

Haque 168

Last 30 days Overall leaderboard