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 / Sort Column from Diffe...
Power Apps
Unanswered

Sort Column from Different Datasource in Gallery

(0) ShareShare
ReportReport
Posted on by 6,048 Super User 2024 Season 1

28.png

Gallery item Code:

SortByColumns(
Search(
AddColumns(
Filter(
Zishan_ITPathFinderCandidate,
Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
Technology.Value = drpTechnology.Selected.Value || drpTechnology.Selected.Value = "All",
Created >= DateFrom.SelectedDate && Created <= DateAdd(
DateTo.SelectedDate,
1,
Days
)
),
"AssignToTxt",
AssignTo.Value,
"StatusTxt",
Status.Value
),
SearchBox.Text,
"FirstName",
"LastName"
),
varColumn,
If(
varSort,
Descending,
Ascending
)
)

 

Code on Sorting Arrows:

UpdateContext({varColumn :"AssignToTxt"});
UpdateContext({varSort:false});

 

Code on Total Submission Colum:

CountRows(Filter(Zishan_ITPathFinderSubmissionDetail,CandidateParentId=ThisItem.ID))

 

I can sort this gallery from all values except Total Submission. Please help

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @zmansuri 

    Please consider changing your Formula to the following:

    SortByColumns(
     Search(
     AddColumns(
     AddColumns(
     Filter(Zishan_ITPathFinderCandidate,
     Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
     Technology.Value = drpTechnology.Selected.Value || drpTechnology.Selected.Value = "All",
     Created >= DateFrom.SelectedDate && Created <= DateAdd(DateTo.SelectedDate, 1, Days)
     ),
     "AssignToTxt", AssignTo.Value,
     "StatusTxt", Status.Value,
     "SubmissionRecs", Filter(Zishan_ITPathFinderSubmissionDetail,CandidateParentId=ID)
     ),
     "SubmissionCount", CountRows(SubmissionRecs)
     ),
     SearchBox.Text,
     "FirstName",
     "LastName"
     ),
     varColumn,
     If(varSort, Descending, Ascending)
    )

     

    Change your Formula on the Total Submission label Text property to:

       ThisItem.SubmissionCount

     

    Change the Formula on the sorting arrow for the Submission Count column to include "SubmissionCount" as the value to assign to the varColumn variable.

     

    I hope this is helpful for you.

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    29.png

    Above code doesn't give any error. But, doesn't sort. Also "Thisitem.SubmissionCount" doesn't show the value. Which was showing before.

    Gallery's Data source is "Zishan_ItPathFinder_Candidate"

    and Submission data source is "Zishan_ItPathFinderSubmissionDetails".

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @zmansuri 

    I'm confused... I provided the Gallery Items property in the last post, but you are stating that the Items property is Zishan_ItPathFinder_Candidate

    Can you expand on what you are stating?

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    There are 2 gallerys and 2 data source.

    gallery1: Candidate Gallery.

    gallery1.Datasouce: Candidate_Datasource.

    gallery2: Submission Gallery

    gallery2.Datasource : Submission_Datasource.

     

    one candidate can have multiple submission.

     

    There is a ParentID column in Submission table which links to ID column of the candidate table.

     

    The gallery you are seeing in below picture has "Candidate" as datasource. But this particular label i rounded takes data from submission table match it with Candidate_ID clolum and shows me the total number of submission count of that particular candidate. I can sort all other columns in the gallery because they are from the same data sources as mentioned in the item property of that gallery. But somehow can't sort "Total Submission" because it's coming from another data source.

    randy.png

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @zmansuri 

    I understand the two datasources, but I provided you with a formula for the Items property of the Gallery...what have you done with that?  That is key to getting what you want.

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Below is the code of Gallery Item Property.

    SortByColumns(
    Search(
    AddColumns(
    AddColumns(
    Filter(Zishan_ITPathFinderCandidate,
    Status.Value = drpStatus.Selected.Value || drpStatus.Selected.Value = "All",
    Technology.Value = drpTechnology.Selected.Value || drpTechnology.Selected.Value = "All",
    Created >= DateFrom.SelectedDate && Created <= DateAdd(DateTo.SelectedDate, 1, Days)
    ),
    "AssignToTxt", AssignTo.Value,
    "StatusTxt", Status.Value,
    "SubmissionRecs", Filter(Zishan_ITPathFinderSubmissionDetail,CandidateParentId=ID)
    ),
    "SubmissionCount", CountRows(SubmissionRecs)
    ),
    SearchBox.Text,
    "FirstName",
    "LastName"
    ),
    varColumn,
    If(varSort, Descending, Ascending)
    )

     

    Below is the Label's Text Property. There is no data if i use "Thisitem.Submission"

    rand1.png

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    rand2.png

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @zmansuri 

    Very good!

    So what kind of column is CandidateParentId in your list?

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    ParentIdSubmission is in Submission Data source. It takes it value from ID column of Candidate Datasource. So, it links which submission belongs to which candidate.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @zmansuri 

    Yes, but I was asking about the CandidateParentId column in the Zishan_ITPathFinderSubmissionDetail datasource. How is that defined?  That seems to be where the error is coming into play.

     

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 Apps

#1
Vish WR Profile Picture

Vish WR 883

#2
Valantis Profile Picture

Valantis 571

#3
11manish Profile Picture

11manish 477

Last 30 days Overall leaderboard