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 / Merging multiple datat...
Power Automate
Suggested Answer

Merging multiple datatables

(1) ShareShare
ReportReport
Posted on by 80

Hi,

I need to merge multiple specific datatables, which I have managed to do. However, there are times a table may not exist and if that happens I want it to leave the "blank" or table that doesn't exist and merge the other specified tables. In this particular case, DT7 didn't exist, but next month there may be a table for it but not  a table for the other.  How do I fix this in the Run.Net script action below, thank you. 

 

P.S shared a shared a possible solution about a month ago but for some reason, I can't open the images and don't see the solution shared on this new platform.

 

 

 

  • Suggested answer
    CU16071609-1 Profile Picture
    6,255 Moderator on at
    Hi GenAI,
     
    You can add some code like this before you merge any datatable.
     
    // Check if DataTables are null
    if (DT1 != null)
    {
    DT.Merge(DT1);
    }
  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at
    Hi @
     
    Instead of using .net script, you can use merge datatable action in power automate desktop which helps to merge the datatable one by one. see below for reference
     

     
    Here if you see we are appending the datatables dt1, dt2 and dt3 to a list List1 and looping through list and merging each datatable to final datatable after checking whether they are empty or not.
     
    Also by variable not exists- what did you meant ? does that mean a empty datatable with no rows present in it ?
     
     
    Thanks & Regards,
    Nived N 
    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs
     Found my answer helpful? Please consider marking it as the solution!
     Your appreciation keeps me motivated. Thank you!
  • GenAi Profile Picture
    80 on at
    @Deenuji Loganathan I tried your method but didn't work. I got the error and have shared part of the flow below relating to the part I am getting the error. Please share any solution you may have. Thank you
     
     
  • Suggested answer
    JuanPuello Profile Picture
    5 on at
    Hello @GenAi,
     
    Power Automate Desktop just added built-in actions to join or merge DataTables. They are located under Variables - Data table.
     
    You can use the "Merge data tables" action to merge your tables one by one and also you can add an if condition to check if the table is empty before merging it.
     
     
    This is the link for the documentation for this action:
    https://learn.microsoft.com/en-us/power-automate/desktop-flows/actions-reference/variables#mergedatatablesaction

    If you can't see this action, please update your PAD.
     
     
    Regards!
    Juan Puello

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

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 331 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard