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 2 collections ...
Power Apps
Unanswered

Compare 2 collections and list all changes

(0) ShareShare
ReportReport
Posted on by 14

Hi, 

 

I have to create a history log which lists all changes between versions of saved data.

I added option to version all records related to specific protocol number. In nutshell I'm collecting all data related to specific protocol number, then I'm updating column with version +1 and then patch collection to source as new records. In the end I have multiple rows of same data but version of it is different. Versioned data will be always in view mode and version "0" will be always in edit mode, if anything changes and there is need to version it up you just create another version. What I'm struggling with is to compare versions and list all differences between them. 

The log should say which field changed and to what

for example: 'Sample Name' changed from: XXXX to YYYY. 

 

As data source im using Dataveres. I added additional column "ID". While editing version '0' ID of record is saved in another column so all versioned rows of data has exactly same ID as version 0. now i want to compare 2 collections e.g. Version 1 and 2 and see which columns changed and from what to what. 

Do you have any ideas how to do it? 

 

Categories:
I have the same question (0)
  • PawelL Profile Picture
    14 on at

    I found a solution, pasting code if anyone would look for something similar:

    ClearCollect(colDifferences, {});
    
    ForAll(
     CollStudyInformationVersionComparison1,
     With(
     {correspondingItem: LookUp(CollStudyInformationVersionComparison2, SLP_ID = CollStudyInformationVersionComparison1[@SLP_ID])},
     If(
     IsBlank(correspondingItem),
     Collect(colDifferences, {Field: "SLP_ID", OldValue: CollStudyInformationVersionComparison1[@SLP_ID], NewValue: "Item Not Found in Collection 2"}),
     If(
     CollStudyInformationVersionComparison1[@cr334_studyname] <> correspondingItem[@cr334_studyname],
     Collect(colDifferences, {Field: "Study Name", OldValue: CollStudyInformationVersionComparison1[@cr334_studyname], NewValue: correspondingItem[@cr334_studyname]})
     );
     If(
     CollStudyInformationVersionComparison1[@cr334_drugname] <> correspondingItem[@cr334_drugname],
     Collect(colDifferences, {Field: "Drug Name", OldValue: CollStudyInformationVersionComparison1[@cr334_drugname], NewValue: correspondingItem[@cr334_drugname]})
     );
     If(
     CollStudyInformationVersionComparison1[@cr334_therapyareaindication] <> correspondingItem[@cr334_therapyareaindication],
     Collect(colDifferences, {Field: "Therapy Area & Indication", OldValue: CollStudyInformationVersionComparison1[@cr334_therapyareaindication], NewValue: correspondingItem[@cr334_therapyareaindication]})
     );
     If(
     CollStudyInformationVersionComparison1[@cr334_studyphase] <> correspondingItem[@cr334_studyphase],
     Collect(colDifferences, {Field: "Study Phase", OldValue: CollStudyInformationVersionComparison1[@cr334_studyphase], NewValue: correspondingItem[@cr334_studyphase]})
     );
     If(
     CollStudyInformationVersionComparison1[@cr334_protocoltitle] <> correspondingItem[@cr334_protocoltitle],
     Collect(colDifferences, {Field: "Protocol Title", OldValue: CollStudyInformationVersionComparison1[@cr334_protocoltitle], NewValue: correspondingItem[@cr334_protocoltitle]})
     );
     If(
     CollStudyInformationVersionComparison1[@cr334_croconductingstudy] <> correspondingItem[@cr334_croconductingstudy],
     Collect(colDifferences, {Field: "CRO Conducting study", OldValue: CollStudyInformationVersionComparison1[@cr334_croconductingstudy], NewValue: correspondingItem[@cr334_croconductingstudy]})
     )
     )
     )
    );

     

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 181 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 112 Super User 2026 Season 2

Last 30 days Overall leaderboard