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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Show latest approved v...
Power Apps
Unanswered

Show latest approved version of sharepoint document in Gallery

(0) ShareShare
ReportReport
Posted on by 25

Hi all!

In my Power App I have a gallery showing all files in a (SharePoint) document library. For this library, content approval is set to required and Minor version are created.

 

By default, the gallery will of course show all items.

 

How can I filter my gallery such that only the latest approved version will show to the user?

Filtering by "Approval Status" is not an option, as it will also hide the previous version(s).

 

 

Filter('SP Library', 'Content approval status' = "Approved")

 

 

For example: I want to show Version 2.0 (approved) to the user but 2.5 (draft) exists. If the user selects the document, version 2.0 is opened (not 2.5).

 

Thanks in advance for your help!

 

 

Categories:
I have the same question (0)
  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at

    hey @Gerard__ 

     

    try this instead:

     

    Collect(
    ApprovedItems,
    Filter(
    'SP Library',
    'Content approval status' = "Approved" &&
    'Version Number' = Max(
    Filter('SP Library', Title = ThisRecord.Title && 'Content approval status' = "Approved").'Version Number'
    )
    )
    );

    // Use 'ApprovedItems' as the items source for your gallery

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Gerard__ Profile Picture
    25 on at

    @mmbr1606, thanks for your reply!

     

    I can't get it to work. For some reason the bold part is not working for me:

    Max(
    Filter('SP Library', Title = ThisRecord.Title && 'Content approval status' = "Approved").'Version number'

     

    For Title I'm using 'Title (Title0)' because the person setting up this library created a new title column for some reason.

    I'm running the collect function in the OnStart property of my app.

     

    Also, I'm not sure what this part is supposed to do so I do not have a clear idea what to change in order to make it work.

    In the mean time, I solved this issue by using the "Draft Item Security" option in SharePoint. Would still be interested though in how to fix this within PowerApps!

  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at

    hey @Gerard__ 

     

    please try this:

    Collect(
     ApprovedItems,
     Filter(
     'SP Library',
     'Content approval status' = "Approved" &&
     'Version Number' = Max(
     Filter(
     'SP Library', 
     'Title (Title0)' = ThisRecord.'Title (Title0)' &&
     'Content approval status' = "Approved"
     ).'Version Number'
     )
     )
    );

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Gerard__ Profile Picture
    25 on at

    Hi @mmbr1606 

    I can't get it to work.

     

    Not sure how the (default) 'Version number' column is configured within SharePoint, but PowerApps Expects a number and apparantly isn't getting it. It seems that the following is not providing a number: 

    Filter(
     'SP Library', 
     'Title (Title0)' = ThisRecord.'Title (Title0)' &&
     'Content approval status' = "Approved"
     ).'Version number'

     

  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at

    hey @Gerard__ 

     

    try this please:

    Filter(
     'SP Library', 
     'Title (Title0)' = ThisRecord.'Title (Title0)' &&
     'Content approval status' = "Approved"
    ).Value('Version number')

     

    the Value() function converts text into number format.

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Gerard__ Profile Picture
    25 on at

    That's not working either... 

     

    I tried the collect syntax without the 'Version number' = Max() part, and that is working.  

    As soon as I integrate that part it breaks down.

     

    Collect(
     ApprovedItems,
     Filter(
     'Document Management System',
     'Content approval status' = "Approved" && 'Version number' = Max(
     Filter(
     'Document Management System',
     'Title (Title0)' = ThisRecord.'Title (Title0)' && 'Content approval status' = "Approved"
     ).Value('Version number')
     )
     )
    );

     

  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at

    we can try a different approach:

    // First, create a collection to store the maximum version numbers for each title
    ClearCollect(
     MaxVersions,
     AddColumns(
     GroupBy(
     Filter(
     'Document Management System',
     'Content approval status' = "Approved"
     ),
     "Title (Title0)",
     "AllItems"
     ),
     "MaxVersion",
     Max(AllItems, 'Version number')
     )
    );
    
    // Now, use this collection in your main Collect function
    Collect(
     ApprovedItems,
     Filter(
     'Document Management System',
     'Content approval status' = "Approved" &&
     'Version number' = LookUp(MaxVersions, 'Title (Title0)' = ThisRecord.'Title (Title0)').MaxVersion
     )
    );

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Gerard__ Profile Picture
    25 on at

    The ClearCollect part works and returns a table with all approved documents.

    The Collect part remains empty after running the OnStart.

     

  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at

    hey @Gerard__ 

     

    good to say one part works, for the other try this please:

     

    Collect(
     ApprovedItems,
     Filter(
     'Document Management System',
     'Content approval status' = "Approved" &&
     'Version number' = LookUp(MaxVersions, 'Title (Title0)' = Title (Title0), MaxVersion)
     )
    );

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Gerard__ Profile Picture
    25 on at

    The table remains empty still...

     

    Also, because of the MaxVersions table having only Approved documents, how will this function make all other documents show up which are now "draft" but do have an older "published" version?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard