Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Take the results from two Power Automate SharePoint REST API queries that have been appended together and sort the total results by Rank

(0) ShareShare
ReportReport
Posted on by

I followed an awesome online YouTube tutorial for using Power Automate to query SPO REST API to obtain search results and send the results back to Power Apps (Search File Content  in Power Apps from SharePoint Document Libraries).  Those results are then JSON Parsed and pushed into a Table to show up in a Gallery.  The single-site-search result is sorted by Rank at the API side so no problems with the return. I then wanted to go further and create a universal search; search across two separate SharePoint sites and append the results into one mega result list creating one mega results gallery.  However, since I'm appending search2 onto search1 the larger totalsearchresults is no longer sorted by Rank.  search1 is sorted by Rank and then, separately, search2 is sorted by rank.

No big deal, sort when I'm in Power Apps?  But I can't figure it out.

 

A single-search-result:

Flow run results is placed in a variable; varSearchResults.  Flow responds to PowerApps as searchresults.

 

Gallery items is set to:

Table(ParseJSON(varSearchResults.searchresults))

 

Labels inside the Gallery: 

LookUp(Table(ThisItem.Value.Cells),ThisRecords.Value.Key="Title").Value.Value

LookUp(Table(ThisItem.Value.Cells),ThisRecords.Value.Key="Rank").Value.Value

etc...

 

The actual search results in JSON look basically like:

{"Cells":[

     { "Key" : "Title",

        "Value": "TitleOfThing"

     },

     {"Key":"Rank",

      "Value":"900"

    }

           ]

 

and so on.  However, I can't figure out how to Sort or SortByColumns in the Gallery Items (aka Table(ParseJSON(varSearchResults.searchresults) to sort the entire large multi-site-search return by Rank.  When I append search1 and search2 together and substring it out so it can Parse correctly in Power Apps, thereby creating a multi-site-search result,  the second search might have an item of Rank 999 but it gets pushed to the bottom of the line in the Gallery when it may be the true first in line.

Hopefully that all makes sense and hopefully someone can be of help?

 

 

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,580

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,909

Leaderboard