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 Automate
Suggested Answer

Compare two datatable

(0) ShareShare
ReportReport
Posted on by 45
 
I got this steps and code from chatgpt. I have extracted data from website. I want to compare the data from current with old one to see if got any new changes. The data is 155 row in 2 columns. Is this steps and coding correct? When I run it, the loop section is like running forever for about 44 minutes but still not finish. is this normal? So I try to change the first item url in the old data, let it run and stop halfway to see if it can capture the changes. but seems like the name of the item is not coming out. only this come out : "" & "Updated: " & CurrentSOP[0] & NewLine. Can someone help me please? How should I do it?
I have the same question (0)
  • stampcoin Profile Picture
    5,158 Super User 2026 Season 1 on at
    @laclws Hi,
     
    I think there are some tiny logic problem.
    see below pseudocode:
    For each CurrentSOP in ExtractedSOPList
        Set MatchFound = 'False'
    
        For each OldSOP in BaselineSOPList
            If CurrentSOP[0] = OldSOP[0]   // when row found
                Set MatchFound = 'True'
    
                If CurrentSOP[1] <> OldSOP[1]   ← different link
                    Set UpdatedSOPs = %UpdatedSOPs% + 'Updated: ' + %CurrentSOP[0]% + %NewLine%
                End
    
                Exit loop          //this must sit here
            End                     // end of the “If CurrentSOP[0]”
        End                         //end of the inner For-each
    
        If %MatchFound% = 'False'
            Set NewSOPs = %NewSOPs% + 'New: ' + %CurrentSOP[0]% + %NewLine%
        End
    End  
     
  • laclws Profile Picture
    45 on at
    Thanks stampcoin for your sharp eye. Now its not looping forever. 
     
     
    But the display message show: UpdatedSOPs: "" & "Updated: " & CurrentSOP[0] & NewLine. It still cannot capture the item name that has been updated manually by me for testing. 
     
    I believe there is something wrong with the above value for the variable set for UpdatedSOPs. Can you help me to look at the above formula? 
     
    New update: I'm revising the steps to ask Chatgpt to just compare the url only which is column 1. able to get some results although messy. I believe the above formula got something wrong as I'm not able to get more than one item(url) as I manually edited 2 url for testing.
     
  • stampcoin Profile Picture
    5,158 Super User 2026 Season 1 on at
    @laclws Hi,
    CurrentSOP[0] ,should be inside %CurrentSOP[0]%,
    NewLine, if this is a variable, should be wrapped in %%.
     
    before the loop, make sure :
    Set NewSOPs with empty value
    Set UpdatedSOPs with empty value
     
    give it a try. feel free if you still get problem.
     
  • Suggested answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at
     
    Can you try this flow design, i believe this reduces the execution time 
     
    Variables.CreateNewDatatable InputTable: { ^['Column1', 'Column2'], [$'''AB1''', $'''Data'''], [$'''AB2''', $'''HJK'''], [$'''AB3''', $'''OLK'''], [$'''AB4''', $'''ASD'''], [$'''AB5''', 123] } DataTable=> ExtractedSOPList
    Variables.CreateNewDatatable InputTable: { ^['Column1', 'Column2'], [$'''AB1''', $'''Data12'''], [$'''AB2''', $'''HJK1'''], [$'''AB3''', $'''OLK'''] } DataTable=> BaselineSOPList
    SET NewSOPs TO $'''%''%'''
    SET UpdatedSOPs TO $'''%''%'''
    LOOP FOREACH CurrentSOP IN ExtractedSOPList
        Variables.FindOrReplaceInDataTable.FindItemInDataTableByColumnIndex DataTable: BaselineSOPList AllMatches: False ValueToFind: CurrentSOP[0] MatchCase: False MatchEntireCellContents: True ColumnNameOrIndex: 0 DataTableMatches=> MatchesDt
        IF MatchesDt.RowsCount = 0 THEN
            Text.AppendLine Text: NewSOPs LineToAppend: $'''New SOP: %CurrentSOP[0]%''' Result=> NewSOPs
        ELSE
            Text.ToNumber Text: MatchesDt[0][0] Number=> RowIndex
            IF BaselineSOPList[RowIndex][1] <> CurrentSOP[1] THEN
                Text.AppendLine Text: UpdatedSOPs LineToAppend: $'''Updated SOP: %CurrentSOP[0]%''' Result=> UpdatedSOPs
            END
        END
    END
    
     
     

    Thanks & Regards,
    Nived N

    Stay connected:
    LinkedIn | YouTube | Blogs

    Was this answer helpful?
    If yes, please mark it as the solution by selecting the checkbox in the discussion thread.
    Your feedback motivates me to keep contributing. Thank you!

     
  • Suggested answer
    Riyaz_riz11 Profile Picture
    4,150 Super User 2026 Season 1 on at
    Hi,
     

    1: Create a dictionary of old SOPs

    1. Initialize Dictionary

      • Action: Set Variable

      • Name: OldSOPDict

      • Value: Dictionary()

    2. Loop through BaselineSOPList

      For each OldSOP in BaselineSOPList
      Set variable
      Name: OldSOPDict
      Value: Add item to dictionary %OldSOPDict%
      Key = %OldSOP[
      0]%
      Value = %OldSOP[1]%

     Step 2: Loop through Current SOPs

    For each CurrentSOP in ExtractedSOPList
    If OldSOPDict contains key %CurrentSOP[
    0]% then
    If %OldSOPDict[CurrentSOP[
    0]]% <> %CurrentSOP[1]% then
    Set variable UpdatedSOPs = %UpdatedSOPs% +
    "Updated: " + %CurrentSOP[0]% + %NewLine%
    Else
    Set variable NewSOPs = %NewSOPs% +
    "New: " + %CurrentSOP[0]% + %NewLine%
     
     
    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz
  • laclws Profile Picture
    45 on at
     
    I redo again the formula using remove common lists action. I find this to be more friendly and easy for me to understand. But still I cannot get the correct results. 
     
    here is my flow:
    here is my csvtable from web extraction.
     
    I just want to compare the url under column value #2 from same website at different times of extraction for eg monthly.
     
    is my formula ok?
     
    I found some prblm with the formula. and also the way i test my data. will post my update later

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 784

#2
Valantis Profile Picture

Valantis 581

#3
Haque Profile Picture

Haque 545

Last 30 days Overall leaderboard