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 Apps / Compare two collection...
Power Apps
Answered

Compare two collections, output what is different

(0) ShareShare
ReportReport
Posted on by 238

Afternoon all, I'm trying to find a way to notify a user of what changes were made to an edit form within my app.

I have created two collections, one when the edit form page is visible

PPSA_0-1596542345611.png

And another which is on the onchange property of my dropdown boxes.

PPSA_1-1596542398199.png

This works well in as much as it shows the modified data in the second collection.

I need to be able to compare the two though, filter to only show those that have been modified / do not match.

End goal is to then send a html table of the changes to a user - just not sure on how to compare the two, many thanks.

PPSA_2-1596542530923.png

 









Categories:
I have the same question (0)
  • KrishnaV Profile Picture
    5,023 on at

    Hi @PPSA ,

     

    I see you are creating the collections with multiple columns create the collections with Row orientation as below:

    Clear(OriginalRecordUserPermissions)
    Collect(OriginalRecordUserPermissions,{FiledName:"PO1",OldValue:DataCardValue43.SelectedText.Value})
    Collect(OriginalRecordUserPermissions,{FiledName:"PO2",OldValue:DataCardValue45.SelectedText.Value}) and so on....

    Do the same to changed values collection also.

    And then try this to find the changes:

    ForAll(OriginalRecordUserPermissions,ForAll(NewRecordUserPermissions,If(OldValue=newValue,Collect(colChanges,{FieldName:FieldName,FieldValue:newValue}))))

     
    I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

    Regards,
    Krishna
    If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

  • PPSA Profile Picture
    238 on at

    Thanks for your response @KrishnaV ,

    I've restructed both collections now as below.

    PPSA_0-1596546155331.png

    PPSA_1-1596546171998.png


    I added a button with your for all expression in to test and it isn't producing expected results, no doubt I may have misunderstood something?

    PPSA_2-1596546249315.pngPPSA_3-1596546263586.png

    I only changed the one record from 0 to 1.

    Thanks



  • PPSA Profile Picture
    238 on at

    @KrishnaV  i have changed the for all expression slightly to be <> instead of = as I want to create the record for what has changed.

    Now when I test this I get the modified record but 20 lines for each change, can we change this to just one line per change?

    Thanks

    PPSA_0-1596550067744.png

     

  • PPSA Profile Picture
    238 on at

    Small work around was to filter the gallery with FirstN(colChanges,Sum(CountRows(colChanges)/20))

    Working for what I need although there's probably a fix somewhere.

  • Verified answer
    KrishnaV Profile Picture
    5,023 on at

    Sorry I was away for a while, try this.

    ForAll(Addcolumns(OriginalRecordUserPermissions, "oldField",FieldName)
    ForAll(NewRecordUserPermissions, 
     If(FieldName = oldField && OldValue <> newValue, Collect(colChanges, {
     	FieldName: FieldName,
     	FieldValue: newValue
     }))))

    Once again sorry for the trouble and delay 😞


    I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

    Regards,
    Krishna
    If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

  • PPSA Profile Picture
    238 on at

    Thanks @KrishnaV , I have this working now, just need to place the collection into a html table to be emailed out now.

    I see your fairly active on here and know your stuff, could you have a little look at this thread i posted a few days back?

    Only comment on there so far is somebody else is experiencing a similar issue.

    Thanks for your time

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Losing-data-when-close-and-open-again/m-p/647699#M206058

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 483

#2
WarrenBelz Profile Picture

WarrenBelz 399 Most Valuable Professional

#3
11manish Profile Picture

11manish 327

Last 30 days Overall leaderboard